程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> C語言 >> C >> C語言問答 >> c語言問題,求源程序,急求!

c語言問題,求源程序,急求!

編輯:C語言問答

c語言問題,求源程序,急求!

2. 求平方根
輸入1 個實數x,計算並輸出其平方根(保留1 位小數)。
例:輸入 17
輸出 The square root of 17.0 is 4.1

3.溫度轉換
設計一個程序將華氏溫度轉換成攝氏溫度c = 5/9(f-32)
輸入華氏溫度(實型)
輸出的攝氏溫度結果保留兩位小數

4. 計算旅途時間
輸入2 個整數time1 和time2,表示火車的出發時間和到達時間,計算並輸出旅途時間。
(有效的時間范圍是0000 到2359,不需要考慮出發時間晚於到達時間的情況。)
例:輸入 712 1411 (出發時間是7:12,到達時間是14:11)
輸出 The train journey time is 6 hrs 59 mins.

5. 數字加密
輸入1 個四位數,將其加密後輸出。方法是將該數每一位上的數字加9,然後除以10 取余,做為該位上的新數字,最後將第1 位和第3 位上的數字互換,第2 位和第4 位上的數字互換,組成加密後的新數。
例:輸入 1257
輸出 The encrypted number is 4601

最佳回答:

#include<stdio.h>
#include<math.h>

void main()
{
float x,root;
printf("enter a numnber:\n");
scanf("%f\n",&x);
root=sqrt(x);
printf("the square root of %.1f%.1f\n",x,root);
}

void main()
{
float f,c;
printf("enter the huashiwendu:\n");
scanf("%f",&f);
c=(f-32)*5/9;
printf("seshi wendu is: %.2f\n",c);
}

void main()
{
int time1,time2,sh,sm,ah,am,time_h,time_m;
scanf("enter two hour:%d\n%d\n",&time1,&time2);
sh=time1/100;sm=time1%100;
ah=time2/100;am=time2%100;
if(am<sm) { ah--;am+=60;}
time_h=ah-sh;
time_m=am-sm;
printf("the train journey time is %dhrs%dmins\n",time_h,time_m);
}

void main()
{
int inum,a,b,c,d,onum;
printf("enter a number:\n");
scanf("%d\n",&inum);
a=inum/1000; a=(a+9)%10;
b=(inum/100)%10; b=(b+9)%10;
c=(inum/10)%10; c=(c+9)%10;
d=inum%10; d=(d+9)%10;
onum=c*1000+d*100+a*10+b;
printf("the encrypted number is %d\n",onum);
}

大概就是這樣,希望有幫助~
  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved