{
"question_id": 7460415, "question_title": "编写一万年历系统(2021年)", "question_content": "<p>要求:模仿现实生活中的挂历。\n当前页以系统当前日期的月份为准显示当前月的每一天(显示出日及对应的星期几)。\n当系统日期变到下一月时,系统自动翻页到下一月。\n </p>", "difficulty": "简单", "answer_id": 53445491, "answer_content": "<p>到底要C版本,还是C++版本啊</p>\n\n<pre>\n<code class=\"language-cpp\">#include <stdio.h>\n \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}\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 \n\tscanf("%d",&y);\n\tfor(i=1;i<y;i++)\n\t\tsum+=year(i);\n\t\n\tweek=(sum+1)%7;\t\t//表示该年1月1日为星期几\n\t\n\tif(year(y)==366)\n\t\tdays[1]=29;\t\n \n\tprintf("\\n%d年日历如下:\\n\\n",y);\n \n\tfor(i=0;i<12;i++)\n\t{\n\t\tprintf(" %d月 \\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 \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"
}