반응형

1071번

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));

		String[] numbers = br.readLine().split(" ");

		for (int i = 0; i < numbers.length; i++) {
			if (numbers[i].equals("0")) {
				break;
			} else {
				bw.write(numbers[i] + "\n");
			}
		}

		bw.flush();
		bw.close();

	}
}

 - JAVA에는 goto문이 없음

 

1072번

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);

		int numCount = scan.nextInt();

		for (int i = 0; i < numCount; i++) {
			System.out.println(scan.nextInt());
		}
		
		scan.close();
	}
}

 

1073번

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);

		while (true) {
			int num = scan.nextInt();

			if (num == 0) {
				break;
			} else {
				System.out.println(num);
			}
		}

		scan.close();
	}
}

 

1074번

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));

		int numCount = Integer.parseInt(br.readLine());

		for (int i = numCount; i > 0; i--) {
			bw.write(String.valueOf(i));
			bw.newLine();
		}

		bw.flush();
		bw.close();

	}
}

 

1075번

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));

		int numCount = Integer.parseInt(br.readLine());

		for (int i = numCount - 1; i >= 0; i--) {
			bw.write(String.valueOf(i));
			bw.newLine();
		}

		bw.flush();
		bw.close();

	}
}

 

반응형

+ Recent posts