1、加上頭文件#includestdio.h
發(fā)展壯大離不開廣大客戶長期以來的信賴與支持,我們將始終秉承“誠信為本、服務(wù)至上”的服務(wù)理念,堅(jiān)持“二合一”的優(yōu)良服務(wù)模式,真誠服務(wù)每家企業(yè),認(rèn)真做好每個(gè)細(xì)節(jié),不斷完善自我,成就企業(yè),實(shí)現(xiàn)共贏。行業(yè)涉及成都?jí)w彩繪等,在網(wǎng)站建設(shè)、成都營銷網(wǎng)站建設(shè)、WAP手機(jī)網(wǎng)站、VI設(shè)計(jì)、軟件開發(fā)等項(xiàng)目上具有豐富的設(shè)計(jì)經(jīng)驗(yàn)。
2、額,int b不可以賦值為1.8
3、%f改為f,因?yàn)槭禽斎?,所以要傳地址的?/p>
4、scanf后的=掉,這是函數(shù)調(diào)用,不是賦值;
ok:最終程序?yàn)椋?/p>
#includestdio.h
#include conio.h
main()
{int a,b,f,sum;
a=32,b=8;
scanf("%d",f);
sum=f-a/b;
printf("sum is %d\n",sum);
getch();
}
另外,我不知道你的轉(zhuǎn)換公式有沒有錯(cuò)誤,但是感覺有點(diǎn)別扭。
#include "stdio.h"
#include "stdlib.h"
#include "time.h"
void main()
{
char again='y'; //again表示是否終止
int count=0,option; //count存儲(chǔ)輸入無效數(shù)字的次數(shù),option存儲(chǔ)輸入的菜單項(xiàng)
int sum,cha,k,right=0,wrong=0,num1,num2;
while(again=='y'){
printf("===========歡迎你進(jìn)行10以內(nèi)加減法練習(xí)============\n");
printf("=================================================\n");
printf(" 1.加法練習(xí) \n");
printf(" 2.減法練習(xí) \n");
printf(" 3.退出 \n");
printf("=================================================\n");
printf("請(qǐng)輸入1或2或3,并按回車鍵進(jìn)入:"); //顯示歡迎界面
scanf("%d",option);//接受用戶的選擇
switch(option){
case 1: // 加法練習(xí)
system("cls");//清屏
printf("=================================================\n");
printf(" 1.加法練習(xí) \n");
printf("=================================================\n");
printf("\n");
srand(time(0));
for (k=1;k=10;k++){//控制總題數(shù)
num1=rand()%10;
num2=rand()%10;
printf("%d+%d=",num1,num2);
scanf("%d",sum);
if (sum==(num1+num2))
right++;//存儲(chǔ)答對(duì)的題數(shù)
else
wrong++;//存儲(chǔ)答錯(cuò)的題數(shù)
printf("\n");
}
printf("=================================================\n");
printf("你算正確了%d次,錯(cuò)誤了%d次。\n",right,wrong);
break;
case 2: // 減法練習(xí)
system("cls");//清屏
printf("=================================================\n");
printf(" 2.減法練習(xí) \n");
printf("=================================================\n");
srand(time(0));
k=1;
do{
do{
num1=rand()%10;
num2=rand()%10;
}while (num1num2);
printf("\t%d - %d =", num1,num2);
scanf("%d",cha);
printf("\n");
if (cha==(num1-num2))
right++;//存儲(chǔ)答對(duì)的題數(shù)
else
wrong++;//存儲(chǔ)答錯(cuò)的題數(shù)
k++;
}while (k=10);//外循環(huán)控制總題數(shù)
printf("=================================================\n");
printf("你算正確了%d次,錯(cuò)誤了%d次。\n",right,wrong);
break;
case 3: //退出練習(xí)
again='q';
break;
default: //輸入了無效的字符
system("cls");//清屏
count++;
again='s';
printf("=================================================\n");
printf("你第%d次輸入的數(shù)字無效。\n",count);
printf("=================================================\n");
}//switch 語句結(jié)束
if (again=='q')
break;
else if (again=='s'){
again='y';
continue;
}
fflush(stdin); //清楚緩存中的數(shù)據(jù)
printf("=================================================\n");
printf("還想繼續(xù)練習(xí)嗎?(y or n)");
scanf("%c",again);
system("cls");
} //while語句結(jié)束
system("cls");//清屏
printf("============================================================\n");
printf("謝謝您進(jìn)行加減法練習(xí),你是個(gè)愛學(xué)習(xí)的好孩子,祝你學(xué)習(xí)進(jìn)步!\n");
printf("============================================================\n");
}
#include?stdio.h
#include?time.h?
int?main()
{?
time_t?rawtime;?
struct?tm?*?timeinfo;?
time?(?rawtime?);?
timeinfo?=?localtime?(?rawtime?);?
printf?(?"The?current?date/time?is:?%s",?asctime?(timeinfo)?);?
return?0;
}
說明:
time_t // 時(shí)間類型(time.h 定義)?
struct tm { // 時(shí)間結(jié)構(gòu),time.h 定義如下:?
int tm_sec;?
int tm_min;?
int tm_hour;?
int tm_mday;?
int tm_mon;?
int tm_year;?
int tm_wday;?
int tm_yday;?
int tm_isdst;?
}?
time ( rawtime ); // 獲取時(shí)間,以秒計(jì),從1970年1月一日起算,存于rawtime?
localtime ( rawtime ); //轉(zhuǎn)為當(dāng)?shù)貢r(shí)間,tm 時(shí)間結(jié)構(gòu)?
asctime() // 轉(zhuǎn)為標(biāo)準(zhǔn)ASCII時(shí)間格式:?
//就是直接打印tm,tm_year 從1900年計(jì)算,所以要加1900,月tm_mon,從0計(jì)算,所以要加1