TA的每日心情 | 开心 2014-6-18 08:29 |
---|
签到天数: 14 天 [LV.3]偶尔看看II
滴水大师
 
- 积分
- 2345
|
题目
解决代码及点评
- <pre code_snippet_id="91880" snippet_file_name="blog_20131202_1_2646179" class="cpp" name="code"></pre><pre code_snippet_id="91880" snippet_file_name="blog_20131202_1_2646179" class="cpp" name="code"><pre code_snippet_id="91880" snippet_file_name="blog_20131202_1_2646179" class="cpp" name="code"><pre code_snippet_id="91880" snippet_file_name="blog_20131202_1_2646179" class="cpp" name="code"><pre code_snippet_id="91880" snippet_file_name="blog_20131202_1_2646179" class="cpp" name="code">/*
- 15. 已知某年不是闰年,给定该年某一天的月份和日期,
- 求这一天是该年的第几天。
- */
- #include <stdio.h>
- #include <stdlib.h>
- void main()
- {
- int day, month, sum;
- printf("input month, day\n");
- scanf_s("%d%d",&month, &day);
- switch(month)
- {
- case 1: sum = 0; break;
- case 2: sum = 31; break;
- case 3: sum = 59; break;
- case 4: sum = 90; break;
- case 5: sum = 120; break;
- case 6: sum = 151; break;
- case 7: sum = 181; break;
- case 8: sum = 212; break;
- case 9: sum = 243; break;
- case 10:sum = 273; break;
- case 11:sum = 304; break;
- case 12:sum = 334; break;
- default: printf("mouth error!");break;
- }
- sum = sum + day;
- printf("sum = %d\n",sum);
- system("pause");
- }</pre><br></pre></pre></pre>
|
|