我正在学习C,因此我绝对会吮吸...但是我会继续尝试,因为我喜欢它。问题是:我在第16行输入所需的答案,然后程序在此处关闭,而没有提示所需的答案。
#include <stdio.h>
main()
{
int age, year, yob;
char c;
loop:
printf("Type in the current year > ");
scanf("%d", &year);
printf("Type in your year of birth > ");
scanf("%d", &yob);
if (yob < 1891 || yob > year) {
printf("\nStop lying!\n\n");
goto loop;
}
printf("Is your birthday to come? (y/n) > ");
scanf("%c", &c);
if (c == 'n') {
age = year - yob;
printf("\n\tYou are %d years old.\n\n", age);
}
if (c == 'y') {
age = (year - yob) - 1;
printf("\n\tYou are %d years old.\n\n", age);
}
}