반응형
1061번
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(" ");
int num1 = Integer.parseInt(numbers[0]);
int num2 = Integer.parseInt(numbers[1]);
bw.write(String.valueOf(num1 | num2));
bw.flush();
bw.close();
}
}
1062번
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(" ");
int num1 = Integer.parseInt(numbers[0]);
int num2 = Integer.parseInt(numbers[1]);
bw.write(String.valueOf(num1 ^ num2));
bw.flush();
bw.close();
}
}
1063번
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(" ");
int num1 = Integer.parseInt(numbers[0]);
int num2 = Integer.parseInt(numbers[1]);
if(num1 > num2) {
bw.write(String.valueOf(num1));
}else {
bw.write(String.valueOf(num2));
}
bw.flush();
bw.close();
}
}
1064번 - 기본 풀이
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(" ");
int num1 = Integer.parseInt(numbers[0]);
int num2 = Integer.parseInt(numbers[1]);
int num3 = Integer.parseInt(numbers[2]);
if (num1 > num2) {
if (num2 > num3) {
bw.write(String.valueOf(num3));
} else {
bw.write(String.valueOf(num2));
}
} else {
if (num1 > num3) {
bw.write(String.valueOf(num3));
} else {
bw.write(String.valueOf(num1));
}
}
bw.flush();
bw.close();
}
}
1064번 - 다른풀이방법
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.Arrays;
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(" ");
int[] nums = Arrays.stream(numbers).mapToInt(Integer::parseInt).toArray();
Arrays.sort(nums);
bw.write(String.valueOf(nums[0]));
bw.flush();
bw.close();
}
}
1065번
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 (Integer.parseInt(numbers[i]) % 2 == 0) {
bw.write(numbers[i] + "\n");
}
}
bw.flush();
bw.close();
}
}
반응형
'알고리즘 > 코드업 기초 100제' 카테고리의 다른 글
[JAVA]코드업 1071번 ~ 1075번 (0) | 2021.05.02 |
---|---|
[JAVA]코드업 1066번 ~ 1070번 (0) | 2021.04.30 |
[JAVA]코드업 1056번 ~ 1060번 (0) | 2021.04.30 |
[JAVA]코드업 1051번 ~ 1055번 (0) | 2021.04.30 |
[JAVA]코드업 1046번 ~ 1050번 (0) | 2021.04.30 |