;;;;

物联网205202017170542杨镇阳 发表于2020年12月30日
<p>#include &lt;stdio.h&gt;</p><p><br ></p><p>#include &lt;stdlib.h&gt;</p><p><br ></p><p>#include &lt;time.h&gt;</p><p><br ></p><p>#include &lt;windows.h&gt;</p><p><br ></p><p>int leapYear(int year){</p><p><br ></p><p>return(year%4==0&amp;&amp;year%100!=0||year%400==0)?1:0;</p><p><br ></p><p>}&nbsp;</p><p><br ></p><p>void displayOfMonth(int year,int month,int days){</p><p><br ></p><p>int i;</p><p><br ></p><p>int sum;</p><p><br ></p><p>int temp;</p><p><br ></p><p>int j;&nbsp;</p><p><br ></p><p>int sumOfDay(int year,int month);//声明&nbsp;</p><p><br ></p><p>sum=sumOfDay(year,month);//调用&nbsp;</p><p><br ></p><p>temp=sum%7;</p><p><br ></p><p>temp++;</p><p><br ></p><p>printf(&quot;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;%d-%d\n&quot;,year,month);</p><p><br ></p><p>printf(&quot;日\t一\t二\t三\t四\t五\t六\n&quot;);</p><p><br ></p><p>if(temp==7){</p><p><br ></p><p>temp=0;</p><p><br ></p><p>}</p><p><br ></p><p>for(j=1;j&lt;=temp;printf(&quot;\t&quot;),j++);</p><p><br ></p><p>for(i=1;i&lt;=days;i++){</p><p><br ></p><p>printf(&quot;%d\t&quot;,i);</p><p><br ></p><p>if((i+temp)%7==0){</p><p><br ></p><p>printf(&quot;\n&quot;);</p><p><br ></p><p>}</p><p><br ></p><p>}</p><p><br ></p><p>printf(&quot;\n&quot;);</p><p><br ></p><p>}</p><p><br ></p><p>int daysOfMonth(int year,int month){</p><p><br ></p><p>int days;</p><p><br ></p><p>switch(month){</p><p><br ></p><p>case 1:</p><p><br ></p><p>case 3:</p><p><br ></p><p>case 5:</p><p><br ></p><p>case 7:</p><p><br ></p><p>case 8:</p><p><br ></p><p>case 10:</p><p><br ></p><p>case 12:</p><p><br ></p><p>days=31;</p><p><br ></p><p>break;</p><p><br ></p><p>case 4:</p><p><br ></p><p>case 6:</p><p><br ></p><p>case 9:</p><p><br ></p><p>case 11:</p><p><br ></p><p>days=30;</p><p><br ></p><p>break;</p><p><br ></p><p>case 2:</p><p><br ></p><p>days=leapYear(year)?29:28;</p><p><br ></p><p>}</p><p><br ></p><p>return days;</p><p><br ></p><p>}</p><p><br ></p><p>int sumOfDay(int year,int month){</p><p><br ></p><p>int sum=0;</p><p><br ></p><p>int i;</p><p><br ></p><p>int monthofday[2][12]={{31,28,31,30,31,30,31,31,30,31,30,31},</p><p><br ></p><p>{31,29,31,30,31,30,31,31,30,31,30,31}};</p><p><br ></p><p>sum=sum+(year-1)*365;</p><p><br ></p><p>sum+=(year-1)/400*97;</p><p><br ></p><p>sum+=(year-1)%400/100*24;</p><p><br ></p><p>sum+=(year-1)%100/4;</p><p><br ></p><p>for(i=1;i&lt;=month-1;i++){</p><p><br ></p><p>//sum+=daysOfMonth(year,i);</p><p><br ></p><p>sum+=monthofday[leapYear(year)][i-1];</p><p><br ></p><p>//i-1表示数组一定要从0开始:C语言一条线&nbsp;</p><p><br ></p><p>//if(leapYear(year)&amp;&amp;month&gt;2) sum++;&nbsp;</p><p><br ></p><p>}</p><p><br ></p><p>return sum;</p><p><br ></p><p>}</p><p><br ></p><p>void menu(){</p><p><br ></p><p>int temp;</p><p><br ></p><p>int tempyear;</p><p><br ></p><p>int days;</p><p><br ></p><p>int year;</p><p><br ></p><p>int season;</p><p><br ></p><p>int i;</p><p><br ></p><p>int month;</p><p><br ></p><p>char select;</p><p><br ></p><p>int m;</p><p><br ></p><p>while(1){</p><p><br ></p><p>printf(&quot;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;=================================================\n&quot;);</p><p><br ></p><p>printf(&quot;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;1、年月日查询\n&quot;);</p><p><br ></p><p>printf(&quot;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;2、年份查询\n&quot;);&nbsp;</p><p><br ></p><p>printf(&quot;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;3、季度查询\n&quot;);</p><p><br ></p><p>printf(&quot;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;4、前六月查询 \n&quot;);</p><p><br ></p><p>printf(&quot;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;5、后六月查询\n&quot;);</p><p><br ></p><p>printf(&quot;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;6、退出本程序\n&quot;);</p><p><br ></p><p>printf(&quot;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;=================================================\n&quot;);</p><p><br ></p><p>&nbsp; &nbsp; select=getchar();</p><p><br ></p><p>if(select=='1'){</p><p><br ></p><p>printf(&quot;请您输入您要查询的具体日期,格式:年-月\n&quot;);</p><p><br ></p><p>scanf(&quot;%d-%d&quot;,&amp;year,&amp;month);</p><p><br ></p><p>system(&quot;color A7&quot;);</p><p><br ></p><p>getchar();</p><p><br ></p><p>system(&quot;cls&quot;);</p><p><br ></p><p>displayOfMonth(year,month,daysOfMonth(year,month));</p><p><br ></p><p>printf(&quot;请等待五秒后重新输入您的选择\n&quot;);</p><p><br ></p><p>Sleep(5000);</p><p><br ></p><p>system(&quot;cls&quot;);</p><p><br ></p><p>&nbsp; }else if(select=='2'){</p><p><br ></p><p>&nbsp; printf(&quot;请您输入您要查询的具体年份,格式:年\n&quot;);</p><p><br ></p><p>&nbsp; scanf(&quot;%d&quot;,&amp;year);</p><p><br ></p><p>&nbsp; system(&quot;color B5&quot;);</p><p><br ></p><p>&nbsp; getchar();</p><p><br ></p><p>&nbsp; system(&quot;cls&quot;);</p><p><br ></p><p>for(i=1;i&lt;=12;displayOfMonth(year,i,daysOfMonth(year,i)),i++);</p><p><br ></p><p>printf(&quot;请等待五秒后重新输入您的选择\n&quot;);</p><p><br ></p><p>Sleep(5000);</p><p><br ></p><p>system(&quot;cls&quot;);</p><p><br ></p><p>&nbsp; }else if(select=='3'){</p><p><br ></p><p>&nbsp; printf(&quot;请输入您要查询的某年某季度,格式为:年-季度\n&quot;);</p><p><br ></p><p>&nbsp; scanf(&quot;%d-%d&quot;,&amp;year,&amp;season);</p><p><br ></p><p>&nbsp; system(&quot;color C6&quot;);</p><p><br ></p><p>&nbsp; getchar();</p><p><br ></p><p>&nbsp; system(&quot;cls&quot;);&nbsp; &nbsp; for(i=(season-1)*3+3;</p><p><br ></p><p>i&lt;=season*3+2;displayOfMonth(tempyear,temp,daysOfMonth(tempyear,temp)),i++){</p><p><br ></p><p>&nbsp; switch(season){</p><p><br ></p><p>&nbsp; case 1:</p><p><br ></p><p>&nbsp; &nbsp; &nbsp; printf(&quot;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 春夜喜雨&nbsp; \n&quot;);</p><p><br ></p><p>&nbsp; &nbsp; &nbsp; printf(&quot;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 杜甫&nbsp; &nbsp; &nbsp;\n&quot;);</p><p><br ></p><p>&nbsp; printf(&quot;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;好雨知时节,\n&quot;);</p><p><br ></p><p>&nbsp; printf(&quot;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;当春乃发生。\n&quot;);</p><p><br ></p><p>&nbsp; printf(&quot;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;随风潜入夜,\n&quot;);</p><p><br ></p><p>&nbsp; printf(&quot;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;润物细无声。\n&quot;);</p><p><br ></p><p>&nbsp; break;</p><p><br ></p><p>case 2:</p><p><br ></p><p>&nbsp; &nbsp; printf(&quot;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;晓出净慈寺送林子方\n&quot;);</p><p><br ></p><p>&nbsp; &nbsp; printf(&quot;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 杨万里\n&quot;);</p><p><br ></p><p>printf(&quot;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;毕竟西湖六月中,\n&quot;);</p><p><br ></p><p>printf(&quot;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;风光不与四时同。\n&quot;);</p><p><br ></p><p>printf(&quot;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;接天莲叶无穷碧。\n&quot;);</p><p><br ></p><p>printf(&quot;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;映日荷花别样红。\n&quot;);</p><p><br ></p><p>break;</p><p><br ></p><p>case 3:</p><p><br ></p><p>&nbsp; &nbsp; printf(&quot;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;秋夜曲&nbsp; &nbsp; &nbsp;\n&quot;);</p><p><br ></p><p>&nbsp; &nbsp; printf(&quot;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 王维&nbsp; &nbsp; &nbsp; \n&quot;);</p><p><br ></p><p>printf(&quot;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;桂魄初生秋露微,\n&quot;);</p><p><br ></p><p>printf(&quot;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;轻罗已薄未更衣.\n&quot;);</p><p><br ></p><p>printf(&quot;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;银筝夜久殷勤弄,\n&quot;);</p><p><br ></p><p>printf(&quot;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;心怯空房不忍归.\n&quot;);</p><p><br ></p><p>break;</p><p><br ></p><p>case 4:</p><p><br ></p><p>&nbsp; &nbsp; printf(&quot;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 梅花&nbsp; &nbsp; \n&quot;);</p><p><br ></p><p>&nbsp; &nbsp; printf(&quot;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;王安石&nbsp; &nbsp;\n&quot;);</p><p><br ></p><p>printf(&quot;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;墙角数枝梅,\n&quot;);</p><p><br ></p><p>printf(&quot;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;凌寒独自开.\n&quot;);</p><p><br ></p><p>printf(&quot;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;遥知不是雪,\n&quot;);</p><p><br ></p><p>printf(&quot;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;为有暗香来.\n&quot;);</p><p><br ></p><p>break;</p><p><br ></p><p>}</p><p><br ></p><p>temp=i;</p><p><br ></p><p>tempyear=year;</p><p><br ></p><p>if(temp&gt;12){</p><p><br ></p><p>tempyear++;</p><p><br ></p><p>temp-=12;</p><p><br ></p><p>}</p><p><br ></p><p>&nbsp; &nbsp; }</p><p><br ></p><p>&nbsp; &nbsp; printf(&quot;请等待五秒后重新输入您的选择\n&quot;);</p><p><br ></p><p>Sleep(5000);</p><p><br ></p><p>system(&quot;cls&quot;);</p><p><br ></p><p>&nbsp; &nbsp; }else if(select=='4'){</p><p><br ></p><p>&nbsp; &nbsp; printf(&quot;请您输入要查询的某年上半年的日历,格式:年\n&quot;);</p><p><br ></p><p>&nbsp; &nbsp; scanf(&quot;%d&quot;,&amp;year);</p><p><br ></p><p>&nbsp; &nbsp; system(&quot;color E3&quot;);</p><p><br ></p><p>&nbsp; &nbsp; getchar();</p><p><br ></p><p>&nbsp; &nbsp; system(&quot;cls&quot;);</p><p><br ></p><p>for(i=1;i&lt;=6;displayOfMonth(year,i,daysOfMonth(year,i)),i++);</p><p><br ></p><p>printf(&quot;请等待五秒后重新输入您的选择\n&quot;);</p><p><br ></p><p>Sleep(5000);</p><p><br ></p><p>system(&quot;cls&quot;);</p><p><br ></p><p>&nbsp; &nbsp; }else if(select=='5'){</p