72.json 3.0 KB
Newer Older
每日一练社区's avatar
test  
每日一练社区 已提交
1
{
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
  "question_id": 7460415,
  "question_title": "编写一万年历系统(2021年)",
  "question_content": "<p>要求&#xff1a;模仿现实生活中的挂历。\n当前页以系统当前日期的月份为准显示当前月的每一天(显示出日及对应的星期几)。\n当系统日期变到下一月时,系统自动翻页到下一月。\n </p>",
  "difficulty": "简单",
  "answer_id": 53445491,
  "answer_content": "<p>到底要C版本&#xff0c;还是C&#43;&#43;版本啊</p>\n\n<pre>\n<code class=\"language-cpp\">#include &lt;stdio.h&gt;\n \nint year(int y)\n{\n\tif ((y%4&#61;&#61;0) &amp;&amp; (y%100!&#61;0) || y%400&#61;&#61;0)\n\t\treturn 366;\n\telse\n\t\treturn 365;\n}\n \nint main()\n{\n\tint y;\n\tint i,j,sum&#61;0;\t\n\tint begin,week;\n\tint days[12]&#61;{31,28,31,30,31,30,31,31,30,31,30,31};\n \n\tscanf(&#34;%d&#34;,&amp;y);\n\tfor(i&#61;1;i&lt;y;i&#43;&#43;)\n\t\tsum&#43;&#61;year(i);\n\t\n\tweek&#61;(sum&#43;1)%7;\t\t//表示该年1月1日为星期几\n\t\n\tif(year(y)&#61;&#61;366)\n\t\tdays[1]&#61;29;\t\n \n\tprintf(&#34;\\n%d年日历如下&#xff1a;\\n\\n&#34;,y);\n \n\tfor(i&#61;0;i&lt;12;i&#43;&#43;)\n\t{\n\t\tprintf(&#34;       %d月          \\n&#34;,i&#43;1);\n\t\tprintf(&#34;  7  1  2  3  4  5  6\\n&#34;);\n\t\tprintf(&#34;&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;\\n&#34;);\n\t\tbegin&#61;1;\n\t\tfor(j&#61;0;j&lt;week;j&#43;&#43;)\n\t\t\tprintf(&#34;   &#34;);\n\t\twhile(begin&lt;&#61;days[i])\n\t\t{\n\t\t\tprintf(&#34;%3d&#34;,begin);\n\t\t\tbegin&#43;&#43;;\n\t\t\tweek&#61;(week&#43;1)%7;\n\t\t\tif(week%7&#61;&#61;0)\n\t\t\t\tprintf(&#34;\\n&#34;);\n\t\t}\n\t\tprintf(&#34;\\n\\n&#34;);\n \n\t}\n\t\n\t\n \n\treturn 0;\n}</code></pre>\n\n<p> </p>\n",
  "tag_name": "c语言",
  "cpp": "#include <stdio.h>\nint year(int y)\n{\n\tif ((y%4==0) && (y%100!=0) || y%400==0)\n\t\treturn 366;\n\telse\n\t\treturn 365;\n}\nint main()\n{\n\tint y;\n\tint i,j,sum=0;\t\n\tint begin,week;\n\tint days[12]={31,28,31,30,31,30,31,31,30,31,30,31};\n\tscanf(\"%d\",&y);\n\tfor(i=1;i<y;i++)\n\t\tsum+=year(i);\n\tweek=(sum+1)%7;\t\t\n\tif(year(y)==366)\n\t\tdays[1]=29;\t\n\tprintf(\"\\n%d年日历如下:\\n\\n\",y);\n\tfor(i=0;i<12;i++)\n\t{\n\t\tprintf(\"\t   %d月\t\t  \\n\",i+1);\n\t\tprintf(\"  7  1  2  3  4  5  6\\n\");\n\t\tprintf(\"=====================\\n\");\n\t\tbegin=1;\n\t\tfor(j=0;j<week;j++)\n\t\t\tprintf(\"   \");\n\t\twhile(begin<=days[i])\n\t\t{\n\t\t\tprintf(\"%3d\",begin);\n\t\t\tbegin++;\n\t\t\tweek=(week+1)%7;\n\t\t\tif(week%7==0)\n\t\t\t\tprintf(\"\\n\");\n\t\t}\n\t\tprintf(\"\\n\\n\");\n\t}\n\treturn 0;\n}",
  "topic_link": "https://bbs.csdn.net/topics/600469950",
  "status": 1,
  "keywords": "算法高阶,数论算法,算法问题选编,RSA公钥加密系统",
  "license": "csdn.net",
  "notebook": {
    "cpp": "https://codechina.csdn.net/csdn/csdn-daily-code/-/jupyter/master/data/notebook/answer/ipynb/cpp/72.ipynb?type=file"
  },
  "notebook_enable": 1,
  "author": "qq_42023987"
每日一练社区's avatar
test  
每日一练社区 已提交
19
}