JAVA/JAVA Algorithm, Datastruct

[Algorithm] JAVA 코드업 기초 100제 (기초-반복실행구조) 1071 ~ 1077

큐범 2022. 9. 4. 03:12

1071 : [기초-반복실행구조] 0 입력될 때까지 무한 출력하기1(설명)

public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.nextLine();
		
		String[] array = s.split(" ");
		
		for(String x : array) {
			if(!x.equals("0")) {
				System.out.println(x);
			}else {
				break;
			}
		}
	}

1072 : [기초-반복실행구조] 정수 입력받아 계속 출력하기(설명)

public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int key = sc.nextInt(); 
		int[] array = new int[key];
		
		for(int i=0; i<array.length; i++) {
			array[i] = sc.nextInt();
		}
		
		for(int x : array) {
			System.out.println(x);
		}
		
	}

1073 : [기초-반복실행구조] 0 입력될 때까지 무한 출력하기2(설명)

public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(true) {
			int i = sc.nextInt();
			
			if(i==0) break;
			System.out.println(i);
		}
	}

1074 : [기초-반복실행구조] 정수 1개 입력받아 카운트다운 출력하기1(설명)

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

		while(i!=0) {
			System.out.println(i);
			i--;
		}
	}

1075 : [기초-반복실행구조] 정수 1개 입력받아 카운트다운 출력하기2(설명)

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

		while(i!=0) {
			i--;
			System.out.println(i);
		}
	}

1076 : [기초-반복실행구조] 문자 1개 입력받아 알파벳 출력하기(설명)

public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char c = sc.next().charAt(0);

		for(int i=97; i<=c; i++) {
			System.out.print(Character.toString(i)+" ");
		}
	}

1077 : [기초-반복실행구조] 정수 1개 입력받아 그 수까지 출력하기(설명)

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

		for(int i=0; i<=c; i++) {
			System.out.println(i);
		}
	}