ZKX's LAB

计算某年某月有几天c语言 c语言 万年历。不知为计算某年某月多少天的函数返回值是16000+,求指教

2021-04-05知识5

C语言计算某年某月某日 是该年的第几天 for里面因该是i=1;i;i+ include int leap(int year) { int leap1;if(year%400=0|(year%4=0&year%100。0)) leap1=1;else leap1=0;return leap1;} int main() 。

编写计算莫年某月有多少天用C语言 include<;stdio.h>;int main(void){int year,mouth;printf(\"Input year:\");scanf(\"%d\",&year);printf(\"Input mouth:\");scanf(\"%d\",&mouth);switch(mouth){case 1:case 3:case 5:case 7:case 8:case 10:case 12:printf(\"There are 31 days in%d mouth.\\n\",mouth);break;case 4:case 6:case 9:case 11:printf(\"There are 30 days in%d mouth.\\n\",mouth);break;case 2:if((year%400=0)|(year%4=0&year%100。0))printf(\"There are 29 days in%d mouth.\\n\",mouth);elseprintf(\"There are 28 days in%d mouth.\\n\",mouth);break;default:printf(\"Input error mouth.\\n\");break;} return 0;}

C语言计算某年某月某日为该年的第几天 #includevoid main(){int y,m,d;int sum=0;int flog;标识是否是闰年printf(\"请输入年月日(yyyy-mm-dd)\\n\");scanf(\"%4d-%2d-%2d\",&y,&m,&d);if((y%4=0&y%100。0)|y%400=0)flog=1;elseflog=0;while((y)|(m>;12|m)|(d|d>;31)|((m%2=0)&(d=31))|((flog=1)&(m=2)&(d>;28))){printf(\"input errro。\\n\");printf(\"请输入年月日(yyyy-mm-dd)\\n\");scanf(\"%4d-%2d-%2d\",&y,&m,&d);}switch(m-1){case 12:sum+31;case 11:sum+30;case 10:sum+31;case 9:sum+30;case 8:sum+31;case 7:sum+31;case 6:sum+30;case 5:sum+31;case 4:sum+30;case 3:sum+31;case 2:if(flog=1)/这里改32313133353236313431303231363533e59b9ee7ad9431333337616461一下sum+28;elsesum+30;case 1:sum+31;break;这里加上一个break语句default:printf(\"非法月份\\n\");break;}sum=sum+d;if(flog=1)printf(\"%d is leap year。\\n\",y);printf(\"这一天是这年的第%d天\",sum);}

#计算某年某月有几天c语言

随机阅读

qrcode
访问手机版