#include "stdio.h"
struct student
{
int year;
int month;
int day;
};
year(int year)
{
if((year%4==0&&year%100==0)||(year%400==0))
return 1;
else
return 0;
}
month(int n)
{
switch(n)
{
case 1:return 31;
case 2:return 28;
case 3:return 31;
case 4:return 30;
case 5:return 31;
case 6:return 30;
case 7:return 31;
case 8:return 31;
case 9:return 30;
case 10:return 31;
case 11:return 30;
case 12:return 31;
}
}
void main()
{
struct student p1,p2;
int sum=0,i,sumbe=0;
printf("请输入你的出生年、月、日:");
scanf("%d%d%d",&p1.year,&p1.month,&p1.day);
printf("请输入今天的年、月、日:");
scanf("%d%d%d",&p2.year,&p2.month,&p2.day);
for(i=1;i
sumbe=sumbe+month(i);
if(p1.year>2||(p1.month==2&&p1.day==30))
sumbe=sumbe+year(p1.year);
sumbe+=p1.day;
for(i=1;i
sum=sum+month(i);
if(p2.year>2||(p2.month==2&&p2.day==30));
sum=sum+year(p2.year);
sum=sum+365*(p2.year-p1.year);
for(i=p1.year;i
sum=sum+year(i);
sum=sum+year(p2.year);
sum=sum+p2.day;
sum=sum-sumbe;
printf("%d",sum);
}
阅读(939) | 评论(0) | 转发(0) |