728x90
반응형
11.20
A+B - 5
package baekjoon;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.StringTokenizer;
public class java_1120 {
public static void main(String[] args) {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
int a, b;
try{
while(true) {
StringTokenizer st = new StringTokenizer(br.readLine(), " ");
a = Integer.parseInt(st.nextToken());
b = Integer.parseInt(st.nextToken());
if(a==0 && b==0) {
break;
}
else {
bw.write((a+b) + "\n");
}
}
bw.flush();
bw.close();
} catch (IOException e) {
System.out.println("오류 발생");
}
}
}
11.21
A+B - 4
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.StringTokenizer;
public class Main {
public static void main(String[] args) {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
try{
StringTokenizer st;
while(true) {
String line = br.readLine();
// if(line == null) {//이클립스에서 작동하지 않음
if (line == null || line.equals("")) {
break;
}
st = new StringTokenizer(line);
int a = Integer.parseInt(st.nextToken());
int b = Integer.parseInt(st.nextToken());
bw.write(a + b + "\n");
}
br.close();
bw.flush();
bw.close();
} catch (IOException e) {
System.out.println("오류 발생");
}
}
}
11.22
package baekjoon;
import java.util.Scanner;
public class java_1122 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
int[] a = new int[N];
for (int i=0; i<N; i++) {
int num = sc.nextInt();
a[i] = num;
}
int b = sc.nextInt();
int count=0;
for(int i=0; i<N ;i++) {
if(a[i]==b)
count++;
}
System.out.println(count);
}
}
11.23
package baekjoon;
import java.util.Scanner;
public class java_1123 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
int X = sc.nextInt();
int[] a = new int[N];
for (int i=0; i<N; i++) {
int num = sc.nextInt();
a[i] = num;
}
for(int i=0; i<N ;i++) {
if(a[i]<X)
System.out.print(a[i]+" ");
}
}
}
11.24
package baekjoon;
import java.util.Scanner;
public class java_1124 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
int[] a = new int[N];
for (int i=0; i<N; i++) {
int num = sc.nextInt();
a[i] = num;
}
int max=a[0];
int min=a[0];
for(int i=1; i<N ;i++) {
if(max<a[i])
max=a[i];
if(min>a[i])
min=a[i];
}
System.out.println(min+ " "+ max);
}
}728x90
반응형
'Study > ☁️ 1일 1문제' 카테고리의 다른 글
| [1일 1문제] 백준 단계별로 풀어보기 8-10번, 1-2번 (1.1~1.5) (1) | 2024.01.05 |
|---|---|
| [1일 1문제] 백준 단계별로 풀어보기 4-7번 (12.26~12.29) (1) | 2023.12.29 |
| [1일 1문제] 백준 단계별로 풀어보기 6-10번 (11.06~11.10) (0) | 2023.11.10 |
| [1일 1문제] 백준 단계별로 풀어보기 1-5번 (10.09~10.13) (1) | 2023.10.13 |
| [1일 1문제] 백준 단계별로 풀어보기 3-7번 (10.02~10.06) (0) | 2023.10.06 |