這裏是我的程序代碼。我得到它說錯誤錯誤「‘(’預期」上線5
「(」預計,上線5以下公共無效工作,對d括號] 。
我不明白這有什麼可予以糾正。
import java.util.*;
class Matrix
{
public void work
{
Scanner Scan= new Scanner(System.in);
int n, i, j;
char a, b, c;
System.out.println("ENTER SIZE: ");
n=Scan.nextInt();
int M[][]= new int[n][n];
System.out.println("FIRST CHARACTER ");
a= Scan.nextChar();
System.out.println("SECOND CHARACTER ");
b= Scan.nextChar();
System.out.println("THIRD CHARACTER ");
c= Scan.nextChar();
if(n<=10)
{
for(i=0; i<n; i++)
{
for(j=0; j<n; j++)
{
if((i==j)||(i+j==n-1))
{
System.out.print(c);
}
else if(((i>j)&&((j==0)||(j==1))) || ((i<j)&&((j==n-2)||(j==n-1))))
{
System.out.print(b);
}
else if(((i<j)&&((i==0)||(i==1))) || ((i>j)&&((i==n-2)||(i==n-1))))
{
System.out.print(a);
}
}
}
}
else
System.out.println("SIZE OUT OF RANGE");
}
}
哪條線5號線? – Zoe