반응형
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();
}
}
반응형
'알고리즘 > 코드업 기초 100제' 카테고리의 다른 글
[JAVA]코드업 1081번 ~ 1085번 (0) | 2021.05.02 |
---|---|
[JAVA]코드업 1076번 ~ 1080번 (0) | 2021.05.02 |
[JAVA]코드업 1066번 ~ 1070번 (0) | 2021.04.30 |
[JAVA]코드업 1061번 ~ 1065번 (0) | 2021.04.30 |
[JAVA]코드업 1056번 ~ 1060번 (0) | 2021.04.30 |