给年份year定义一个宏,以判别该年份是否闰年
网上有一个类似的问题,它的原程序如下:#include<stdio.h>#defineLEAP_YEAR(y)(y)%400==0||(y)%4==0&&(y)%100=...
网上有一个类似的问题,它的原程序如下:
#include<stdio.h>
#define LEAP_YEAR(y)(y)%400==0||(y)%4==0&&(y)%100=0
void main()
{
int year;
scanf("%d",&year);
if(year>=1000 && year<=9999)
{
if(LEAP_YEAR(year))
{
printf("%d is a leap year!\n", year);
}
else
{
printf("%d is not a leap year!\n", year);
}
}
else
{
printf("Input error!\n");
}
}
为什么编译的时候会出现error C2106: '=' : left operand must be l-value,应该怎么改,在线等 展开
#include<stdio.h>
#define LEAP_YEAR(y)(y)%400==0||(y)%4==0&&(y)%100=0
void main()
{
int year;
scanf("%d",&year);
if(year>=1000 && year<=9999)
{
if(LEAP_YEAR(year))
{
printf("%d is a leap year!\n", year);
}
else
{
printf("%d is not a leap year!\n", year);
}
}
else
{
printf("Input error!\n");
}
}
为什么编译的时候会出现error C2106: '=' : left operand must be l-value,应该怎么改,在线等 展开
3个回答
展开全部
#include<stdio.h>
#define LEAP_YEAR(y) (y)%400==0||((y)%4==0&&(y)%100!=0)
main()
{int a;
printf("pleas input the year:");
scanf("%d",&a);
printf("%d\n",a);
if (LEAP_YEAR(a)==1)
printf("%d is leap year\n",a);
else
printf("%d is not leap year\n",a);
}
#define LEAP_YEAR(y) (y)%400==0||((y)%4==0&&(y)%100!=0)
main()
{int a;
printf("pleas input the year:");
scanf("%d",&a);
printf("%d\n",a);
if (LEAP_YEAR(a)==1)
printf("%d is leap year\n",a);
else
printf("%d is not leap year\n",a);
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
(y)%100=0这儿的问题,应该是==0
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询