1. c语言 输入出生日期,并输入当前日期,输出年龄,以天为单位
#include
void
main(){
int
startyear,endyear,startmonth,endmonth,startday,endday,i,p=0,r=0;
printf("请输入出生日期:");
scanf("%d,%d,%d",&startyear,&startmonth,&startday);
printf("请输入现在日期:");
scanf("%d,%d,%d",&endyear,&endmonth,&endday);
while(startyear>endyear||startmonth<0||startmonth>12||endmonth<0||endmonth>12){
printf("输入非法!\n");
printf("请输入出生日期:");
scanf("%d,%d,%d",&startyear,&startmonth,&startday);
printf("请输入现在日期:");
scanf("%d,%d,%d",&endyear,&endmonth,&endday);
}
if(startmonth>endmonth||startday>endday){
endyear-=1;
}
for(i=startyear;i
评论
0
0
加载更多