怎样使用循环
for (i=0;i<4 ;i++ ){
if (positionNumber==4)
{
for ( m=0;m<4 ;m++ )
{
System.out.print(a[m]);
}
break;
}
else if (positionNumber!=4)
{
//a[i]==temp;
if (i==0)
{
a[i] = randomNumber.nextInt(9)+1;
for (k=0,j=i;k<=m ;k++ )
{
if (a[i]!=b[j][k])
{
continue;
}
else
{
for (int n=0; ;n++ )
{
a[i] = randomNumber.nextInt(9)+1;
if (a[i]!=b[j][k])
{
break;
}
}
k=-1;
}
}
}
else if(i!=0)
{
a[i] = randomNumber.nextInt(10);
for (k=0,j=i;k<=m ;k++ )
{
if (a[i]!=b[j][k])
{
continue;
}
else
{
for (int n=0; ;n++ )
{
a[i] = randomNumber.nextInt(10)+1;
if (a[i]!=b[j][k])
{
break;
}
}
k=-1;
}
}
}
for (k=0;k<a.length ;k++ )
{
System.out.print(a[k]);
}
System.out.print("猜对几个数字:");
rightNumber = in.nextInt();
System.out.print("猜对几个位置:");
positionNumber = in.nextInt();
if (positionNumber<tempPosition)
{
positionNumber=tempPosition;
}
else if (positionNumber>tempPosition)
{
tempPosition = positionNumber;
}
else
{
for (j=0;j<10 ;j++ )
{
m=j;
b[i][j]=a[i];
i=i-1;
break;
}
}
//}
}
怎样把这段代码优化