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
載入更多