解题思路:
注意事项:
参考代码:
#include <stdio.h>
#include <stdlib.h>
struct date
{
int year;
int month;
int day;
};
int func(int year)
{
if((year % 400 == 0)||((year % 100 != 0)&&(year % 4 == 0)))
return 1;
else
return 0;
}
int main()
{
struct date Date;
scanf("%d %d %d",&Date.year,&Date.month,&Date.day);
int day[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
int n = 0,i;
if(func(Date.year))
{
if(Date.month > 2)
{
for(i = 0;i < Date.month - 1;i++)
n += day[i];
n = n + Date.day + 1;
}
else
{
for(i = 0;i < Date.month;i++)
n += day[i];
n = n + Date.day;
}
}
else
{
for(i = 0;i < Date.month - 1;i++)
n += day[i];
n = n + Date.day;
}
printf("%d\n",n);
return 0;
}
0.0分
0 人评分
【回文数(二)】 (C++代码)浏览:865 |
2006年春浙江省计算机等级考试二级C 编程题(2) (C语言代码)浏览:467 |
C语言训练-字符串正反连接 (C语言代码)浏览:617 |
C语言程序设计教程(第三版)课后习题6.10 (C语言代码)浏览:1051 |
简单的a+b (C语言代码)浏览:626 |
C语言程序设计教程(第三版)课后习题7.2 (C语言代码)浏览:797 |
C语言程序设计教程(第三版)课后习题6.6 (C++代码)浏览:624 |
C语言程序设计教程(第三版)课后习题6.9 (C语言代码)浏览:624 |
C语言考试练习题_一元二次方程 (C语言代码)浏览:574 |
【蟠桃记】 (C语言代码)浏览:1021 |