看板 TransCSI 關於我們 聯絡資訊
Program: void main(){ int i,j,sum=0,s[5]={1,3,-4,5,-6}; for(i=0;i<5;i++){ for(j=3;j>0;j--){ if(s[i]<j)continue; sum=sum+s[i]; } } printf("%d\n",sum); } The value of "sum" would be_ (a)37 (b)43 (c)55 (d)33 (e) 25 這題怎麼算呢? -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 114.47.11.205
stator:不知道為何,我算出來是負數= = 03/05 11:16
stator:是當IF條件成立才要去做SUM=SUM+S[I]嗎? 03/05 11:17
stator:若不成立,就直接執行下一個迴圈I~題目感覺滿怪 03/05 13:01
thestyle:continue會直接跳過後面程式碼 回到j--作下一次迴圈 03/07 03:11
stator:謝謝樓上的t大,原來continue是這意思~所以答案是e 03/08 13:10