1樓:勝勳
區別很大
假如之前 a的值是5,那麼
while (a = 10) 可以執行,因為a已經變成了10,滿足條件
while (a == 10)不執行,因為a是5,不等於10,所以不滿足條件
2樓:zhangxiaoyang
這個區別?
int b1 = (a = 1);
int b2 = (a == 1);
while(b1);
while(b2);
3樓:forest
完全兩個東西…
馿唇不對馬嘴!都不對!
唯一正確的是:
while (10==a)
…這樣子!
最後講這一次啦! 再寫錯……就
自行改行別幹碼農啦!
4樓:丫丫呀呀呀
a=10是賦值表示式,賦值表示式的值是賦值運算子左側變數的值,也就是a的值10,因為while內表示的是真假,在c語言中非零的值表示真,零表示假,因此10表示真,所以while(a=10)始終是真,會導致無限迴圈無法退出,而while(a==10)則是判斷a是否和10相等,如果相等while內表示真,迴圈繼續,不等則表示假,退出迴圈
5樓:錦心
認真的說的話,這樣寫是有意義的
例如你要表達乙個迴圈,其中有乙個全域性變數在每次進入迴圈時都要初始化為乙個值,你就可以寫
while
(true)它與
while(a
=10)完全等價,而且也很容易理解
退出時用break;就好
當然要是題主不知道=和==的意義的話……書上講的很明白的……(
什麼?你說題主問的是while(a=10);和while(a==10);有什麼區別?
tmp.cpp:3:10: error: stray 『\357』 in program
3 | whilea=10tmp.cpp:3:11: error: stray 『\274』 in program
3 | whilea=10tmp.cpp:3:12: error: stray 『\210』 in program
3 | whilea=10tmp.cpp:3:17: error: stray 『\357』 in program
3 | while(a=10tmp.cpp:3:18: error: stray 『\274』 in program
3 | while(a=10tmp.cpp:3:19: error: stray 『\211』 in program
3 | while(a=10tmp.cpp:3:20: error: stray 『\357』 in program
3 | while(a=10tmp.cpp:3:21: error: stray 『\274』 in program
3 | while(a=10tmp.cpp:3:22: error: stray 『\233』 in program
3 | while(a=10tmp.cpp:4:10: error: stray 『\357』 in program
4 | whilea==10tmp.cpp:4:11: error: stray 『\274』 in program
4 | whilea==10tmp.cpp:4:12: error: stray 『\210』 in program
4 | whilea==10tmp.cpp:4:18: error: stray 『\357』 in program
4 | while(a==10tmp.cpp:4:19: error: stray 『\274』 in program
4 | while(a==10tmp.cpp:4:20: error: stray 『\211』 in program
4 | while(a==10tmp.cpp:4:21: error: stray 『\357』 in program
4 | while(a==10tmp.cpp:4:22: error: stray 『\274』 in program
4 | while(a==10tmp.cpp:4:23: error: stray 『\233』 in program
4 | while(a==10tmp.cpp: In function 『int main()』:
tmp.cpp:3:13: error: expected 『(』 before 『a』
3 | while(a=10tmp.cpp:3:17: error: expected 『)』 before 『while』
3 | while(a=104 | while(a==10tmp.cpp:4:13: error: expected 『(』 before 『a』
4 | while(a==10tmp.cpp:4:18: error: expected 『)』 before 『}』 token
4 | while(a==105tmp.cpp:5:1: error: expected primary-expression before 『}』 token
5(劃掉)(叫你開全形)
C 語言中 main void main 和 int main void 有什麼區別?
Cosmia Fu 為啥沒人用這種形式呢?int main int argc,char argv 我比較喜歡這一種 和int main int argc,char argv,char env Leon int main void 表示返回乙個整數值,不接收任何引數。main 按照老的C語言標準,不寫...
C語言中,break和continue都是跳出迴圈,有啥區別?
兵長喵w 一般這個年齡段都不會長久,非常困難 你們要面對的困難是 1.不小心偷嘗禁果導致懷孕 你們這個年紀,女生還好,男生16歲開始就會想做那種事情,最好是克制,畢竟這個對未成年人的身體發育是有影響的,不是未成年該做的事,留到十八歲以後或者結婚再做,否則後果不堪設想,就算用了tao也還是會有一點懷孕...
C 語言中 extern 變數和 global 變數有什麼區別?
新安當老闆 C語言裡沒有global變數,C 中的global指的是全域性作用域,對應C語言中的檔案作用域,extern指的是鏈結屬性,鏈結屬性和作用域是有區別的。 extern在這種情形中代表需要預留乙個全域性可見的符號。全域性的意思是在鏈結階段可以找到這個符號,因為在鏈結中是沒有非全域性的符號的...