質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
Java

Javaは、1995年にサン・マイクロシステムズが開発したプログラミング言語です。表記法はC言語に似ていますが、既存のプログラミング言語の短所を踏まえていちから設計されており、最初からオブジェクト指向性を備えてデザインされています。セキュリティ面が強力であることや、ネットワーク環境での利用に向いていることが特徴です。Javaで作られたソフトウェアは基本的にいかなるプラットフォームでも作動します。

Q&A

解決済

1回答

934閲覧

javaで分からないエラーが出る。

rink

総合スコア80

Java

Javaは、1995年にサン・マイクロシステムズが開発したプログラミング言語です。表記法はC言語に似ていますが、既存のプログラミング言語の短所を踏まえていちから設計されており、最初からオブジェクト指向性を備えてデザインされています。セキュリティ面が強力であることや、ネットワーク環境での利用に向いていることが特徴です。Javaで作られたソフトウェアは基本的にいかなるプラットフォームでも作動します。

0グッド

0クリップ

投稿2018/10/21 09:50

プログラミング初心者です。以下のプログラムでエラーが出てしまうので、何がダメなのか教えていただきたいです。

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]);
^

僕にとって見たことのないエラーで戸惑っています。どうかよろしくお願いします。

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

ベストアンサー

class あ {

これあってる?

投稿2018/10/21 09:56

y_waiwai

総合スコア87774

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

rink

2018/10/21 10:01

間違ってます。自己解決しました。ありがとうございます!
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問