请看程序①,这是对的,但是我在第十行中将“if(leap)”改成“if(leap=1)”变成程序②,怎么输都是闰年,请问这是怎么回事?程序①#includevoid main(){ int year,leap; scanf("%d",&year); if((year%4==0&&year%100!=0)|
来源:学生作业帮助网 编辑:六六作业网 时间:2025/01/11 05:24:19
请看程序①,这是对的,但是我在第十行中将“if(leap)”改成“if(leap=1)”变成程序②,怎么输都是闰年,请问这是怎么回事?程序①#includevoid main(){ int year,leap; scanf("%d",&year); if((year%4==0&&year%100!=0)|
请看程序①,这是对的,但是我在第十行中将“if(leap)”改成“if(leap=1)”变成程序②,怎么输都是闰年,请问这是怎么回事?
程序①
#include
void main()
{
int year,leap;
scanf("%d",&year);
if((year%4==0&&year%100!=0)||(year%400==0))
leap=1;
else
leap=0;
if(leap)
printf("%d is a leap year\n",year);
else
printf("%d is not a leap year\n",year);
}
程序②
#include
void main()
{
int year,leap;
scanf("%d",&year);
if((year%4==0&&year%100!=0)||(year%400==0))
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)”改成“if(leap=1)”变成程序②,怎么输都是闰年,请问这是怎么回事?程序①#includevoid main(){ int year,leap; scanf("%d",&year); if((year%4==0&&year%100!=0)|
if(leap==1)