큐범
Just do debug
큐범
전체 방문자
오늘
어제
  • 전체보기 (132)
    • 회고 (4)
    • JAVA (16)
      • JAVA 기초 (18)
      • JAVA Algorithm, Datastruct (13)
    • Spring (11)
    • Micro Service Architecture (3)
    • JPA (6)
    • gRPC (4)
    • Network (8)
    • Process (7)
    • Cloud (4)
    • Python (10)
    • Web(vue) (2)
    • UMC (1)
    • DB (9)
    • CS (5)
    • Clean Code (1)
    • TDD (9)

블로그 메뉴

  • 홈
  • 태그
  • 방명록

인기 글

최근 댓글

최근 글

hELLO · Designed By 정상우.
큐범

Just do debug

JAVA/JAVA Algorithm, Datastruct

[Algorithm] JAVA 코드업 기초 100제 (기초-1차원배열, 2차원배열) 1093 ~ 1099

2022. 9. 6. 02:50

1093 : [기초-1차원배열] 이상한 출석 번호 부르기1(설명)

public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s1 = sc.nextLine();
		String s2 = sc.nextLine();
		
		int[] array = new int[23];
		int[] call = Arrays.stream(s2.split(" "))
				.mapToInt(Integer::parseInt)
				.toArray();
		
		for(int i=0; i<Integer.parseInt(s1); i++) {
			array[call[i]]++;
		}
		
		for(int j=1; j<23; j++) {
			System.out.print(array[j]+" ");
		}
	}

1094 : [기초-1차원배열] 이상한 출석 번호 부르기2(설명)

public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int s1 = sc.nextInt();
		int[] array = new int[s1];

		
		for(int i =0; i<s1; i++) {
			array[i] = sc.nextInt();
		}
		
		for(int j = array.length-1; j>=0; j-- ) {
			System.out.print(array[j]+" ");
		}
	}

1095 : [기초-1차원배열] 이상한 출석 번호 부르기3(설명)

public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int s1 = sc.nextInt();
		int[] array = new int[s1];

		
		for(int i =0; i<s1; i++) {
			array[i] = sc.nextInt();
		}
		
		int min=23;
		
		for(int j=0; j<array.length; j++) {
			if(array[j]<min) min= array[j];
		}
		
		System.out.println(min);
	}

1096 : [기초-2차원배열] 바둑판에 흰 돌 놓기(설명)

public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int[][] array = new int[19][19];
		
		for(int i=0; i<n; i++) {
			int x = sc.nextInt();
			int y = sc.nextInt();
			
			array[x][y]=1;
		}
		
		for(int j=1; j<array.length; j++) {
			for(int k=1; k<array.length; k++) {
				System.out.print(array[j][k]);
			}
			System.out.print("\\n");
		}
	}

1097 : [기초-2차원배열] 바둑알 십자 뒤집기(설명)

public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int[][] array = new int[20][20];
		
		for(int i=1; i<array.length; i++) {
			for(int j=1; j<array.length; j++) {
				array[i][j]=sc.nextInt();	
			}
		}
		
		int n = sc.nextInt(); 
		
		for(int i=0; i<n; i++) {
			int x = sc.nextInt();
			int y = sc.nextInt();
			
			for(int j=1; j<array.length; j++) {
				if(array[x][j]==0) array[x][j]=1;
				else array[x][j]=0;
			}
			for(int k=1; k<array.length; k++) {
				if(array[k][y]==0) array[k][y]=1;
				else array[k][y]=0;
			}
		}
		
		
		for(int j=1; j<array.length; j++) {
			for(int k=1; k<array.length; k++) {
				System.out.print(array[j][k]);
			}
			System.out.print("\\n");
		}
	}

1098 : [기초-2차원배열] 설탕과자 뽑기

public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int[][] array;
		
		int h,w,n,l,d,x,y; 
		h=sc.nextInt();
		w=sc.nextInt();
		
		array=new int[h][w];
		
		n=sc.nextInt();
		
		for(int i=0; i<n; i++) {
			l=sc.nextInt();
			d=sc.nextInt();
			x=sc.nextInt();
			y=sc.nextInt();
			
			for(int j=0; j<l; j++) {
				if(d==0) array[x-1][y-1+j]=1;
				else array[x-1+j][y-1]=1;
			}
		}
		
		for(int i=0; i<w; i++) {
			for(int j=0; j<w; j++) {
				System.out.print(array[i][j]+" ");
			}
			System.out.print("\\n");
		}
	}

1099 : [기초-2차원배열] 성실한 개미

public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int[][] array=new int[11][11];
		
		for (int i=1; i<=10; i++) {
			for (int j=1; j<=10; j++) {
				array[i][j] = sc.nextInt();
			}
		}
		
		int x = 2;
		int y = 2;
		
		while(true) {
			if(array[x][y]==0) {
				array[x][y]=9;
				y++;
			}
			if(array[x][y]==1) {
				y--;
				x++;
			}
			if(array[x][y]==2) {
				array[x][y]=9;
				break;
			}else if(array[x][y]+1 ==1 && array[x+1][y]==1) {
				if(array[x][y]==0) array[x][y]=9;
				
				break;
			}
		}
		
		for(int i=1; i<=10; i++) {
			for(int j=1; j<=10; j++) {
				System.out.print(array[i][j]+" ");
			}
			System.out.print("\\n");
		}
	}
    'JAVA/JAVA Algorithm, Datastruct' 카테고리의 다른 글
    • [JAVA] Arrays.sort() Collection.sort() 정렬 알고리즘
    • [Algorithm] JAVA 코드업 기초 100제 (기초-종합) 1078 ~ 1092
    • [Algorithm] JAVA 코드업 기초 100제 (기초-반복실행구조) 1071 ~ 1077
    • [Algorithm] JAVA 코드업 기초 100제 (기초-삼항연산, 선택실행 구조) 1063 ~ 1070
    큐범
    큐범

    티스토리툴바