java 忘備録 2次元 配列 01
public class Main {
public static void main(String args) {
// Scanner sc = new Scanner(System.in);
Scanner sc = new Scanner(System.in);
//Scanner sc2 = new Scanner(System.in);
int loop = sc.nextInt();
/*
// 四角形
for (int i = 0;i < 5; i++) {
for (int j = 0; j < 5;j++) {
System.out.print("■");
}
System.out.println();
}//----------------------------- END for
*/
/*
char fromChar = { {'A','B','C','D','E'},
{'F','G','H','I','J'},
{'K','L','M','N','O'}
};
char toChar = new char[fromChar.length];
// for ループ内で toChar の 下位配列の生成を行う
for(int i = 0;i < fromChar.length; i++) {
toChar[i] = new char[fromChar[i].length];
// データのコピー
for (int j = 0; j < fromChar[i].length; j++) {
toChar[i][j] = fromChar[i][j];
}
}
*/
char fromChar = { {'A','B','C','D','E'},
{'F','G','H','I','J'},
{'K','L','M','N','O'}
};
char toChar = new char[fromChar.length][loop];
// 出力
for (int i = 0;i < toChar.length; i++) {
for (int j = 0; j < toChar[i].length; j++) {
System.out.print(toChar[i][j] + " " + "■" + "★");
}
System.out.println();
}
}
}