printf语句不给定变量名时的个性输出
写程序,判断某一年是否闰年#include <stdio.h>
void main()
{
int year,leap;
scanf("%d",&year);
if(year%4==0)
if(year%100==0)
if(year%400==0) leap=1;
else leap=0;
else leap=1;
else leap=0;
if (leap==1) printf("%d is a leap year.\n",year);
else printf("%d is not a leap year.\n",year);
}
小弟一开始在
if (leap==1) printf("%d is a leap year.\n",year);
else printf("%d is not a leap year.\n",year);
中没有打“,year"只有("%d is a leap year.\n");当输入量时判断是正确的,但前面的年一直是1246.
例如,输入2000时,输出为:1246 is a leap year.
输入1999时,输出为:1246 is not leap year.
请教高手这是怎么个情况?