/ 科创班 /

记录详情

Accepted

/in/foo.c: In function 'leap':
/in/foo.c:29:15: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
 leap=year%4==0&&year%100!=0||year%400==0;
      ~~~~~~~~~^~~~~~~~~~~~~
# 状态 耗时 内存占用
#1 Accepted 2ms 256.0 KiB
#2 Accepted 2ms 256.0 KiB
#3 Accepted 2ms 256.0 KiB
#4 Accepted 2ms 256.0 KiB
#5 Accepted 1ms 256.0 KiB
#6 Accepted 1ms 256.0 KiB
#7 Accepted 2ms 256.0 KiB
#8 Accepted 1ms 256.0 KiB
#9 Accepted 1ms 256.0 KiB
#10 Accepted 2ms 256.0 KiB

代码

#include <stdio.h>
int main()
{
int sum_day(int month,int day);
int leap(int year);
int year,month,day,days;

//printf("input date(year,month,day):");
scanf("%d %d %d",&year,&month,&day);
//printf("%d/%d/%d",year,month,day);
days=sum_day(month,day);  /*调用函数 sum_day*/
if(leap(year)&&month>=3)  /*调用函数 leap*/
days=days+1;
//printf("is the %dth day in this year.\n",days);
printf("%d",days);
return 0;
}
int sum_day(int month,int day) /*函数 sum_day:计算日期*/
{
int day_tab[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
int i;
for(i=1;i<month;i++)
day+=day_tab[i]; /*累 加 所 在 月之前天数*/
return (day);
}
int leap(int year) /*函数 leap:判断是否为闰年*/
{
int leap;
leap=year%4==0&&year%100!=0||year%400==0;
return(leap);
}

信息

递交者
类型
递交
题目
7.18计算日期
题目数据
下载
语言
C
递交时间
2018-07-14 11:14:55
评测时间
2018-07-14 11:14:55
评测机
分数
100
总耗时
20ms
峰值内存
256.0 KiB