ZKX's LAB

c 求某年某月有多少天 C语言计算某年某月某日为该年的第几天

2021-04-09知识6

计算某年某月有多少天 c语言 给伪码days[2][12]={{31,28,31,30,31,30,31,31,30,31,30,31},{31,29,31,30,31,30,31,31,30,31,30,31}}int year(int num);判断平闰年int y=year(某年)?0:1;int i;累加器int month,day;年月for(i=0;i;i+){day+month[y][i];}输出day;

编写计算莫年某月有多少天用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 year,month;printf(\"\\n Please input year:\\n\");scanf(\"%d\",&year);printf(\"enter month:\\n\");scanf(\"%d\",&month);if(year%4=0){if(month=2)printf(\"\\n day=d\",29);else{if(month=4|month=6|month=9|month=11)printf(\"\\n day=d\",30);elseprintf(\"\\n day=d\",31);}}else{if(month=2)printf(\"\\n day=d\",28);else{if(month=4|month=6|month=9|month=11)printf(\"\\n day=d\",30);elseprintf(\"\\n day=d\",31);}}}只是把输入部分改了 输出结果是对的 还有你的32313133353236313431303231363533e58685e5aeb931333330356263判断闰年的方法有误应该是if(i%4=0&i%100。0|i%400=0)则i为闰年

#c 求某年某月有多少天#c 求一百以内的素数

随机阅读

qrcode
访问手机版