æ£ç”例
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
package challenge08; import java.util.Scanner; public class Kiban { public static void main(String[] args) { String msg = "1~8ã®æ•°å—を入力ã—ã¦ãã ã•ã„"; Scanner scan = new Scanner(System.in); String[] w= {"â—‹","â—"}; int[][] h = new int[8][8]; System.out.println(msg); int ii = scan.nextInt(); System.out.println(msg); int jj = scan.nextInt(); h[ii-1][jj-1] = 1; //入力ã®è¡Œã€åˆ—ã«1をセット String str = ""; //8行分ループ for(int i=0; i<h.length; i++){ //8列分ループ for(int j=0; j<h[i].length; j++){ str = str + w[h[i][j]]; } System.out.println(str); //â—‹â—を表示ã™ã‚‹ str = ""; } } } |