解题思路:
注意事项:
参考代码:
#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 人评分
Lucky Word (C++代码)浏览:937 |
C语言训练-排序问题<1> (C语言代码)浏览:1351 |
C语言程序设计教程(第三版)课后习题6.1 (C语言代码)浏览:628 |
C语言训练-求具有abcd=(ab+cd)2性质的四位数 (C语言代码)浏览:567 |
c primer plus 第十二章 12.1小节浏览:377 |
简单的a+b (C语言代码)浏览:694 |
C二级辅导-阶乘数列 (C语言代码)浏览:692 |
剪刀石头布 (C++代码)浏览:1713 |
蛇行矩阵 (C语言代码)浏览:507 |
C语言程序设计教程(第三版)课后习题8.5 (C语言代码)浏览:667 |