日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪(fǎng)問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程资源 > 编程问答 >内容正文

编程问答

用c语言计算高考成绩,C语言计算距离高考剩余时间

發(fā)布時(shí)間:2024/3/13 编程问答 41 豆豆
生活随笔 收集整理的這篇文章主要介紹了 用c语言计算高考成绩,C语言计算距离高考剩余时间 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

每年6月6日定為高考,輸入日期:xxxx.xx.xx,若沒(méi)到6月6日,則算距離今年的,否則算明年的。

#include

#define uint unsigned int

/*月份天數(shù),1月31,2月28/29,3月31,4月30,5月31,6月30,7月31,8月31,9月30,10月31,11月30,12月31*/

/*判斷是否是閏年*/

uint is_ruennian(uint x)

{

if(x%4==0)

{

if(x%100==0)

{

if(x%400==0)

return(1);//是閏年

else

return (0);//不是閏年

}

else

return (1);//是閏年

}

return (0);

}

/*ACII轉(zhuǎn)成int*/

uint asciitoint(char *p,uint n)

{

uint i,temp=0;

for(i=0;i

{

temp*=10;

temp+=*p-48;

}

return (temp);

}

/*計(jì)算距離6月6日的天數(shù)*/

uint caculate_days(uint year,uint month,uint day)

{

uint temp=0;

if(month<6)

{

ca1:

temp+=6-day;

switch (6-month)

{

case 1:

case 2:

case 5:

temp+=(6-month)*30+1;

break;

case 3:

temp+=(6-month)*31;

break;

case 4:

temp+=(6-month)*30;

break;

}

if((6-month>3)&&(is_ruennian(year)==1))

temp+=1;

}

else if(month==6)

{

if(day<=6)

goto ca1;

else

goto ca2;

}

else

{

ca2:

temp+=day-6;

switch (month-6)

{

case 1:

temp+=(month-6)*30+1;

break;

case 2:

case 3:

temp+=(month-6)*30+2;

break;

case 4:

case 5:

temp+=(month-6)*30+3;

break;

case 6:

temp+=(month-6)*30+4;

break;

}

if(is_ruennian(year+1)==1)

temp=366-temp;

else

temp=365-temp;

}

return (temp);

}

void main()

{

uint year,month,day;

char flag=1,time[10];//存放日期

printf("****************這是一個(gè)計(jì)算距離高考還有多少天的工具****************\n");

printf("******************輸入日期的格式為:xxxx.xx.xx**********************\n");

while(flag)

{

printf("請(qǐng)輸入當(dāng)前日期,并按下回車(chē)鍵結(jié)束:");

gets((char *)time);

year=asciitoint((char *)time,4);

month=asciitoint((char *)(time+5),2);

day=asciitoint((char*)(time+8),2);

printf("當(dāng)前日期%d年%d月%d日,",year,month,day);

printf("距離高考還有%d天\n",caculate_days(year,month,day));

printf("結(jié)束請(qǐng)輸入0并按回車(chē),繼續(xù)請(qǐng)輸入1并按回車(chē):");

if(getchar()=='0')

flag=0;

else if(getchar()=='1')

flag=1;

}

}

總結(jié)

以上是生活随笔為你收集整理的用c语言计算高考成绩,C语言计算距离高考剩余时间的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。