我对以下算法有疑问,应该怎么做才能解决这个问题 如果年份不是闰年,我将需要再次键入年份,直到键入的年份是闰年。
int year = 0;
BOOL yearC;
NSLog(@"Enter the year to be tested;");
scanf ("%i", &year);
yearC = ((year % 4 == 0 && year % 100 !=0)|| year % 400 == 0);
if ( yearC )
NSLog (@"It's a leap year.");
else
{
NSLog (@"Nope, it's not a leap year.");
scanf ("%i", &year);
}
}