典型的新手錯(cuò)誤
C語(yǔ)言中判斷兩個(gè)變量是否相等不是用"=",要用"=="
把代碼第二行改成:#define IS(x)x%100!=0&&x%4==0||x%400==0?1:0
編譯就通過(guò)了
代碼24行出現(xiàn) non-lvalue in assignment
代碼24行出現(xiàn) non-lvalue in assignment
#include
#define IS(x)x%100!=0&&x%4=0||x%400=0?1:0
int dayofmonth[13][2]={
0,0,
31,31,
28,29,
31,31,
30,30,
31,31,
30,30,
31,31,
31,31,
30,30,
31,31,
30,30,
31,31,
};
struct Date {
int year;
int month;
int day;
void nextday(){
day++;
if(day>dayofmonth[month][IS(year)]){ // 該行錯(cuò)誤
day=1;
month++;
if(month>12){
month=1;
year++;
}
}
}
};
int buf[4000][13][32];
int abs(int x){
return x>0?-x:x;
}
int main(){
int i=0;
Date tem;
tem.year=0;
tem.day=1;
tem.month=1;
while(tem.year!=4001){
buf[tem.year][tem.month][tem.day]=i;
tem.nextday();
i++;
}
int d1,d2,d3;
int d4,d5,d6;
scanf("%4d%2d%2d",d1,d2,d3);
scanf("%4d%2d%2d",d4,d5,d6);
printf("%d",abs(buf[d4][d5][d6]-buf[d1][d2][d3])+1);
return 0;
}
#include
#define IS(x)x%100!=0&&x%4=0||x%400=0?1:0
int dayofmonth[13][2]={
0,0,
31,31,
28,29,
31,31,
30,30,
31,31,
30,30,
31,31,
31,31,
30,30,
31,31,
30,30,
31,31,
};
struct Date {
int year;
int month;
int day;
void nextday(){
day++;
if(day>dayofmonth[month][IS(year)]){ // 該行錯(cuò)誤
day=1;
month++;
if(month>12){
month=1;
year++;
}
}
}
};
int buf[4000][13][32];
int abs(int x){
return x>0?-x:x;
}
int main(){
int i=0;
Date tem;
tem.year=0;
tem.day=1;
tem.month=1;
while(tem.year!=4001){
buf[tem.year][tem.month][tem.day]=i;
tem.nextday();
i++;
}
int d1,d2,d3;
int d4,d5,d6;
scanf("%4d%2d%2d",d1,d2,d3);
scanf("%4d%2d%2d",d4,d5,d6);
printf("%d",abs(buf[d4][d5][d6]-buf[d1][d2][d3])+1);
return 0;
}
其他人氣:768 ℃時(shí)間:2020-06-03 01:52:05
優(yōu)質(zhì)解答
我來(lái)回答
類(lèi)似推薦
- non-lvalue in assignment是什么意思
- non-lvalue in assignment是什么意思?該怎么解決?講的通俗一點(diǎn),什么左值的不懂
- Assignment has more non-singleton rhs dimensions than non-singleton subscripts
- 大小行星繞地球公轉(zhuǎn)的共同特點(diǎn)是什么
- 2sin45度+|負(fù)根號(hào)2|-根號(hào)8+(3分之一)負(fù)一次方
- 長(zhǎng)100米寬100米是多少平米和幾畝地 長(zhǎng)50米寬50米是多少平米和幾畝地
- 急求一篇英語(yǔ)對(duì)話(huà)兩人的關(guān)于How do you plan your university years?
- "疑是銀河落九天"的"九天"是什么意思?
- 怎么證明(m+n)^2/2+(m+n)/4>mn^(1/2)+nm^(1/2),已知m>0,n>0
- 這段話(huà)是否有語(yǔ)法錯(cuò)誤(英語(yǔ))
- 判斷下列函數(shù)的奇偶性 1,f(x)=3x的四次方+x²分之1 2.f(x)=x分之1 3.f
- ★仿照這樣的寫(xiě)法,用“我漫步在兒童公園里”開(kāi)頭寫(xiě)一段話(huà),寫(xiě)出周?chē)木拔?表達(dá)自己愉快的心情.
猜你喜歡
- 1急 若(2X(的三次方 - (KX)的平方+3被2X+1除后余2,求K的值
- 2I like some bread and milk for breakfast.在這個(gè)句子
- 3連詞成句:a,tomorrow,I,have,test,late,I,stay,can't,out,because
- 4是不是只有熱的物體才能發(fā)光?
- 5根號(hào)Y-1與根號(hào)1-2X互為相反數(shù),求根號(hào)Y除以X
- 6如圖,已知B為線(xiàn)段AC上的一點(diǎn),M是線(xiàn)段AB的中點(diǎn),N為線(xiàn)段AC的中點(diǎn),P為NA的中點(diǎn),Q為MA的中點(diǎn),求MN:PQ的值.
- 7設(shè)A*是三階方陣A的伴隨矩陣,若|A|=2,則秩R(A*)=?
- 8英語(yǔ)單詞大全
- 9宮本武藏的藏的發(fā)音是zang還是cang?
- 10運(yùn)輸隊(duì)要運(yùn)2000件玻璃器皿,按合同規(guī)定,完好無(wú)損運(yùn)到的每件付運(yùn)輸費(fèi)1.2元,如有損壞,每件沒(méi)有運(yùn)輸費(fèi)外,還要賠償6.7元,最后運(yùn)輸隊(duì)得到2005元,運(yùn)輸中損壞了多少件玻璃器皿?
- 11Newspapers and magazines have special interest in the private lives of famous people.
- 1212生肖中,善良的動(dòng)物有