プログラミング初心者です。以下のプログラムでエラーが出てしまうので、何がダメなのか教えていただきたいです。
class あ {
public static void Main(String args[]) {
int c[][] = { {0,0,0,0,0,0,1,0,0,0}, {0,0,1,1,1,1,0,0,0,0}, {0,0,0,0,1,0,0,0,0,0}, {1,1,1,1,1,1,1,1,1,1}, {0,0,0,1,1,1,0,0,0,0}, {1,1,1,0,1,0,1,1,1,1}, {0,0,0,1,1,1,1,0,0,0}, {0,0,0,0,1,0,1,1,0,0}, {0,0,0,1,0,0,0,1,0,0}, {0,0,1,0,0,0,1,1,0,0} }; int xZeroCount[][] = new int[10][10]; int yZeroCount[][]= new int[10][10]; int xOneCount[][] = new int[10][10]; int yOneCount[][] = new int[10][10]; int xZeroCount2[][] = new int[10][10]; int yZeroCount2[][] = new int[10][10]; int xOneCount2[][] = new int[10][10]; int yOneCount2[][] = new int[10][10]; int xZeroCount3[][] = new int[10][10]; int yZeroCount3[][] = new int[10][10]; int xOneCount3[][] = new int[10][10]; int yOneCount3[][] = new int[10][10]; int xZeroCount4[][] = new int[10][10]; int yZeroCount4[][] = new int[10][10]; int xOneCount4[][] = new int[10][10]; int yOneCount4[][] = new int[10][10]; int xZeroCount5[][] = new int[10][10]; int yZeroCount5[][] = new int[10][10]; int xOneCount5[][] = new int[10][10]; int yOneCount5[][] = new int[10][10]; int x,y; xZeroCount[y][x] = 0; x = 0; for(y=0;y<10;y++){ for(x=0;x<10;x++){ while( x < 10 && c[y][x]== 0 ) { xZeroCount[y][x] = xZeroCount[y][x] + 1; x++; } } xOneCount[y][x] = 0; while( x < 10 && c[y][x] == 1 ) { xOneCount[y][x] = xOneCount[y][x] + 1; x++; } } xZeroCount2[y][x] = 0; while( x < 10 && c[y][x] == 0 ) { xZeroCount2[y][x] = xZeroCount2[y][x] + 1; x++; } } xOneCount2[y][x] = 0; while( x < 10 && c[y][x] == 1 ) { xOneCount2[y][x] = xOneCount2[y][x] + 1; x++; } } xZeroCount3[y][x] = 0; while( x < 10 && c[y][x] == 0 ) { xZeroCount3[y][x] = xZeroCount3[y][x] + 1; x++; } } xOneCount3[y][x] = 0; while( x < 10 && c[y][x] == 1 ) { xOneCount3[y][x] = xOneCount3[y][x] + 1; x++; } } xZeroCount4[y][x] = 0; while( x < 10 && c[y][x] == 0 ) { xZeroCount4[y][x] = xZeroCount4[y][x] + 1; x++; } } xOneCount4[y][x] = 0; while( x < 10 && c[y][x] == 1 ) { xOneCount[y][x] = xOneCount[y][x] + 1; x++; } } xZeroCount5[y][x] = 0; while( x < 10 && c[y][x] == 0 ) { xZeroCount5[y][x] = xZeroCount5[y][x] + 1; x++; } } xOneCount5[y][x] = 0; while( x < 10 && c[y][x] == 1 ) { xOneCount5[y][x] = xOneCount5[y][x] + 1; x++; } } } yZeroCount[y][x] = 0; x = 0; for(x=0;x<10;x++){ for(y=0;y<10;y++){ while( x < 10 && c[y][x] == 0 ) { xZeroCount[y][x] = xZeroCount[y][x] + 1; x++; } } yOneCount[y][x] = 0; while( x < 10 && c[y][x] == 1 ) { xOneCount[y][x] = xOneCount[y][x] + 1; x++; } } yZeroCount2[y][x] = 0; while( x < 10 && c[y][x] == 0 ) { xZeroCount2[y][x] = xZeroCount2[y][x] + 1; x++; } } yOneCount2[y][x] = 0; while( x < 10 && c[y][x] == 1 ) { xOneCount2[y][x] = xOneCount2[y][x] + 1; x++; } } yZeroCount3[y][x] = 0; while( x < 10 && c[y][x] == 0 ) { xZeroCount3[y][x] = xZeroCount3[y][x] + 1; x++; } } yOneCount3[y][x] = 0; while( x < 10 && c[y][x] == 1 ) { xOneCount3[y][x] = xOneCount3[y][x] + 1; x++; } } yZeroCount4[y][x] = 0; while( x < 10 && c[y][x] == 0 ) { xZeroCount4[y][x] = xZeroCount4[y][x] + 1; x++; } } yOneCount4[y][x] = 0; while( x < 10 && c[y][x] == 1 ) { xOneCount[y][x] = xOneCount[y][x] + 1; x++; } } yZeroCount5[y][x] = 0; while( x < 10 && c[y][x] == 0 ) { xZeroCount5[y][x] = xZeroCount5[y][x] + 1; x++; } } yOneCount5[y][x] = 0; while( x < 10 && c[y][x] == 1 ) { xOneCount5[y][x] = xOneCount5[y][x] + 1; x++; } } } for(y=0;y<10;y++){ for(x=0;x<10;x++){ System.out.print(""+c[y][x]+" "); } if(x==0){ System.out.print("||"xZeroCount[y][x]); } System.out.print(","+xOneCount[y][x]); System.out.print(","+xZeroCount2[y][x]); System.out.print(","+xOneCount2[y][x]); System.out.print(","+xZeroCount3[y][x]); System.out.print(","+xOneCount3[y][x]); System.out.print(","+xZeroCount4[y][x]); System.out.print(","+xOneCount4[y][x]); System.out.print(","+xZeroCount5[y][x]); System.out.print(","+xOneCount5[y][x]); System.out.print("\n"); } System.out.print("-------------------------\n"); for(x=0;x<10;x++){ for(y=0;y<10;y++){ System.out.print(""+c[y][x]+" "); } System.out.println(","+yZeroCount[y][x]); System.out.println(","+yOneCount[y][x]); System.out.println(","+yZeroCount2[y][x]); System.out.println(","+yOneCount2[y][x]); System.out.println(","+yZeroCount3[y][x]); System.out.println(","+yOneCount3[y][x]); System.out.println(","+yZeroCount4[y][x]); System.out.println(","+yOneCount4[y][x]); System.out.println(","+yZeroCount5[y][x]); System.out.println(","+yOneCount5[y][x]); } } }
代表的なエラーは以下の通りです。
CountFills36.java:57: エラー: ']'がありません
xOneCount2[y][x] = 0;
^
CountFills36.java:57: エラー: ';'がありません
xOneCount2[y][x] = 0;
^
CountFills36.java:57: エラー: <identifier>がありません
xOneCount2[y][x] = 0;
^
CountFills36.java:58: エラー: 型の開始が不正です
while( x < 10 && c[y][x] == 1 ) {
^
CountFills36.java:58: エラー: 型の開始が不正です
while( x < 10 && c[y][x] == 1 ) {
^
CountFills36.java:63: エラー: class、interfaceまたはenumがありません
xZeroCount3[y][x] = 0;
^
CountFills36.java:64: エラー: class、interfaceまたはenumがありません
while( x < 10 && c[y][x] == 0 ) {
^
CountFills36.java:66: エラー: class、interfaceまたはenumがありません
x++;
^
CountFills36.java:67: エラー: class、interfaceまたはenumがありません
}
^
CountFills36.java:174: エラー: class、interfaceまたはenumがありません
System.out.print(","+xZeroCount2[y][x]);
^
僕にとって見たことのないエラーで戸惑っています。どうかよろしくお願いします。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/10/21 10:01