2011-07-31 25 views
0

可以幫助我在下面的簡單代碼?去下一個元素for循環通過語句不是一般的方式

我評論這裏的問題是

TIA

for(int i=0;i<10;i++) 
    { 
if(x[i] !=1000) 
{ 
    //do something 
} 
else 
    { 
//i want it to go to the next i and again check x[i] != 1000,not i++ 
    } 
    if(y != x[i]) 
    { 

    //do something 
} 

} 
+1

'其他{繼續; }'btw什麼是'j ++'? – Gasim

+0

我糾正了我的問題 – Arash

+0

這不是很清楚。例如,「y」是什麼? –

回答

4

我不知道j是誰,但你可能會尋找這樣的:

if(x[i] !=1000) 
{ 
    //do something 
} 
else 
{ 
    //i want it to go to the next i and again check x[i] != 1000,not j++ 
    continue; 
} 
+0

我改正了我的問題,謝謝 – Arash

+0

@arash你想再次檢查'x [i]!= 1000' **而不增加'i' **嗎? – cnicutar

+0

不,我想增加我,但檢查從x [i]!= 1000 – Arash