完全Begginer Coder(2)


残念です。


金曜日に面接があったので、たくさんの問題ができませんでした!!

デジタル長方形2

package algorithm_study_july;

import java.util.Scanner;

public class jungol_1304_숫자사각형3 {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int cnt=1;
		int[][] map = new int[N][N];
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < N; j++) {
				map[j][i]=cnt++;
			}
		}
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < N; j++) {
				System.out.print(map[i][j]+" ");
			}
			System.out.println();
		}
	}
}

デジタル長方形3

package algorithm_study_july;

import java.util.Scanner;

public class jungol_1304_숫자사각형4 {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		
		
		int cnt=1;
		int[][][] map = new int[3][N][N];
		for (int k = 0; k < map.length; k++) {
			
			for (int i = 0; i < N; i++) {
				for (int j = 0; j < N; j++) {
					if(k==0) {
						map[0][i][j]=i+1;
					}
					
					if(k==1) {
						if(i%2==0)
						map[1][i][j]=j+1;
						else
						map[1][i][j]=N-j;
						
					}
						
					if(k==2) {
						map[k][i][j]=(i+1)+(j*(i+1));;
					}
				}
			}
		}
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < N; j++) {
				System.out.print(map[M-1][i][j]+" ");
			}
			System.out.println();
		}
	}
}