我有12個點的3個組我想測試,看看我的數組的12個點是否在395和405之間。然後,我想測試一個組中的所有3個點是否都在400以下。如果是,則輸出消息,但是我的代碼不斷循環。有人可以爲我檢查嗎?即時嘗試測試二維數組的範圍值,但它保持循環
tempi=i;
tempx=x;
for(i=0;i<3;i++)
{
for(x=0;x<4;x++)
{
if(rounded[i][x]<395 || rounded[i][x] >405)
{
System.out.println("there is an error with probes "+rounded[i][x]);
}
else if(values[i=0][x]< 400)
{
System.out.println("all points in element "+tempi+"as they are below 400 needs replaced("+"point "+tempx+" : "+values[i][x]+")");
}
else if(values[i=1][x]<400)
{
System.out.println("all points in element "+tempi+"as they are below 400 needs replaced("+"point "+tempx+" : "+values[i][x]+")");
}
else if(values[i=2][x]<400)
{
System.out.println("all points in element "+tempi+"as they are below 400 needs replaced("+"point "+tempx+" : "+values[i][x]+")");
}
}
}
作品謝謝但我真的需要嵌套for循環或將它運行沒有 – user3188481
對於二維數組,你通常需要嵌套循環。 – Zarathuztra