#include <stdio.h>
#define CURRENTYEAR 2020
int main()
{
int yearBorn, age;
printf("What year were you born?\n");
scanf(" %d", &yearBorn);
if (yearBorn > CURRENTYEAR){
printf("wrong input!\n");
printf("What year were you born?\n");
scanf(" %d", &yearBorn);
}
age = CURRENTYEAR - yearBorn;
printf("\nSo this year you will turn %d on your birthday!\n",age);
if ((yearBorn % 4) == 0){
printf("\nYou were born in a Leap Year--cool!\n");
}
return 0;
}
询问用户的出生年份并计算他们在当年的年龄。
Maxsu
(我是小编编)