打酱油的


私信TA

用户名:1017563043

访问量:4786

签 名:

摸鱼使我快乐

等  级
排  名 935
经  验 3329
参赛次数 0
文章发表 73
年  龄 22
在职情况 学生
学  校 广州松田职业学院
专  业 计算机应用技术

  自我简介:

略略略略略略~~~~

解题思路:switch累加

注意事项:重复使用:while(scanf("%d/%d/%d",&year,&month,&day)!=EOF){ 算法代码 } 

参考代码:

#include <stdio.h>
int main() {
	int year,month,day,total;
	while(scanf("%d/%d/%d",&year,&month,&day)!=EOF) {
		total=0;
		total+=day;
		switch(month-1) {
			case 11:
				total+=30;
			case 10:
				total+=31;
			case 9:
				total+=30;
			case 8:
				total+=31;
			case 7:
				total+=31;
			case 6:
				total+=30;
			case 5:
				total+=31;
			case 4:
				total+=30;
			case 3:
				total+=31;
			case 2:
				total+=28;
			case 1:
				total+=31;
		}
		if(year%400==0||year%4==0&&year%100!=0)
			if(month>2)
				total++;
		printf("%d\n",total);
	}
}


 

0.0分

2 人评分

看不懂代码?想转换其他语言的代码? 或者想问其他问题? 试试问问AI编程助手,随时响应你的问题:

编程语言转换

万能编程问答  

代码解释器

代码纠错

SQL生成与解释

  评论区