/ 科创班 /

记录详情

Runtime Error

/in/foo.c:2:6: warning: return type of 'main' is not 'int' [-Wmain]
 void main()
      ^~~~
/in/foo.c: In function 'main':
/in/foo.c:47:6: warning: 'num' may be used uninitialized in this function [-Wmaybe-uninitialized]
   sum=sum+mon_day(y,m);}
   ~~~^~~~~~~~~~~~~~~~~
/in/foo.c:21:6: note: 'num' was declared here
  int num;
      ^~~
/in/foo.c: In function 'mon_day':
/in/foo.c:39:9: warning: 'num' may be used uninitialized in this function [-Wmaybe-uninitialized]
  return num;;
         ^~~
/in/foo.c: In function 'find':
/in/foo.c:47:6: warning: 'num' may be used uninitialized in this function [-Wmaybe-uninitialized]
   sum=sum+mon_day(y,m);}
   ~~~^~~~~~~~~~~~~~~~~
# 状态 耗时 内存占用
#1 Runtime Error 5ms 256.0 KiB

代码

#include<stdio.h>
void main()
{
	int year,month,day,sum;
	scanf("%d,%d,%d",&year,&month,&day);
	int p(int year);
	int monday(int m);
	int find(int y,int m,int d);
	sum=find(year,month,day);
	printf("%dth\n",sum);
}
int p(int year)
{
	int leap;
	if((year%4==0&&year%100!=0)||(year%400==0))leap=1;
	else leap=0;
	return leap;
}
int mon_day(int y,int m)
{
	int num;
	switch(m)
	{
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:num=31;break;
case 4:
case 6:
case 9:
case 11:num=30;break;
case 2:{if(y&&(m=2)) num=29;
	else num=28;}
	break;
	}
	return num;;
}
int find(int y,int m,int d)
{
	int sum=d;
	while(m>1)
	{
		m=m-1;
		sum=sum+mon_day(y,m);}
	return sum;
}

信息

递交者
类型
递交
题目
给出年、月、日,计算该日是该年的第几天
题目数据
下载
语言
C
递交时间
2018-06-17 17:45:15
评测时间
2018-06-17 17:45:15
评测机
分数
0
总耗时
5ms
峰值内存
256.0 KiB