ZKX's LAB

C语言判断某年某月的某天是该年第几天,这个程序为何是错的 c某年某月有多少天

2021-04-23知识11

C语言中如何用数组改写判断某年某月共有多少天 #includevoid main(){int y,m,d,sum,i;int month[]={0,31,28,31,30,31,30,31,31,30,31,30,31};while(scanf(\"%d%d%d\",&y,&m,&d)。EOF){sum=d;if(y%4=0&y%100。0|y%400=0)month[2]=29;elsemonth[2]=28;for(i=1;i;i+)sum+month[i];printf(\"%d\\n\",sum);}}

编程计算某年某月有多少天 #include\"stdafx.hinclude\"stdlib.hinclude\"stdio.hint countDays(int year,int month){if(year)return 0;switch(month){case 1:case 3:case 5:case 7:case 8:case 10:case 12:return 31;case 4:case 6:case 9:case 11:return 30;case 2:if((year%4。0)|((year%100=0)&(year%400。0)))return 28;elsereturn 29;default:return 0;};}void main(){int year,month;printf(\"年:\");scanf(\"%d\",&year);printf(\"月:\");scanf(\"%d\",&month);int days=countDays(year,month);if(days>;0)printf(\"%d年%d月一共有%d天\\n\",year,month,days);elseprintf(\"输入的年月有误\\n\");system(\"pause\");}

用C语言函数输入某年某月某日,判断这一天是这一年的第几天? include<;stdio.h>;#include<;stdlib.h>;static int daytable[2][13]={ {0,31,28,31,30,31,30,31,31,30,31,30,31},{0,31,29,31,30,31,30,31,31,30,31,30,31}};Get the days 。

#用c语言求某年某月的天数#c某年某月有多少天

随机阅读

qrcode
访问手机版