编写一个程序,把您的年龄转换成天数并显示二者的值,c语言的。

如题所述

不考虑 你是1900年出生 和2100年这两个非闰年,在这之间,每四年一个闰年,你的年龄中有多少个四年,你的日期修正就加上多少个1(2月29号 ,补一天),如,你22岁,有5个 四年,其中包括5个闰年,再计算今年是否是闰年,若是,再加1,即 年龄除以4的值加今年是否闰年(1 or 0),然后加上365*你的岁数。套用一部分楼上代码。
#include "stdio.h"

void main()
{
int age = 0;
printf("Input your age:");
scanf("%d",&age);
if (age <= 0 || age >= 200)
{
printf("Your age is incorrect, please input again:");
scanf("%d",&age);
}

printf("Your age is:%d, and the days are :%d\n",age,age*365+age/4);//补上闰年的
}
温馨提示:答案为网友推荐,仅供参考
相似回答