반응형
1. 1330
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int first = scan.nextInt();
int second = scan.nextInt();
if(first > second) System.out.println(">");
else if(first < second) System.out.println("<");
else System.out.println("==");
}
}
2. 9498
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int grade = scan.nextInt();
if(grade >= 90 && grade <= 100) System.out.println("A");
else if(grade >= 80 && grade <= 89) System.out.println("B");
else if(grade >= 70 && grade <= 79) System.out.println("C");
else if(grade >= 60 && grade <= 69) System.out.println("D");
else System.out.println("F");
}
}
3. 2753
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int year = scan.nextInt();
if(year % 4 == 0 && year % 100 != 0 || year % 400 == 0)
System.out.println("1");
else System.out.println("0");
}
}
4. 2884
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int h = scan.nextInt();
int m = scan.nextInt();
if(m < 45) {
m += 60;
h--;
if(h < 0) h = 23;
}
System.out.println(h);
System.out.println( m - 45);
}
}
5. 10817
import java.util.ArrayList;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int a = scan.nextInt();
int b = scan.nextInt();
int c = scan.nextInt();
int temp = 0;
ArrayList<Integer> testing = new ArrayList<Integer>();
testing.add(a);
testing.add(b);
testing.add(c);
for(int i = 0; i < testing.size() - 1; i++) {
for(int j = 1; j <testing.size(); j++) {
if(testing.get(i) > testing.get(j)) {
temp = testing.get(j);
testing.set(j, testing.get(i));
testing.set(i, temp);
}
}
}
System.out.println(testing.get(1));
}
}
반응형
'IT > 알고리즘' 카테고리의 다른 글
백준 4단계(11/23/19)(10952, 10951, 1110) (0) | 2019.11.23 |
---|---|
백준 3단계(11/23/19)(2739, 10950, 8393, 15552, 2741, 2742, 11021, 11022, 2438, 2439, 10871) (0) | 2019.11.23 |
백준 1단계(11/23/19)(2557, 10718, 10171, 10172, 7287, 1000, 1001, 10998, 1008, 10869, 10430, 2588) (0) | 2019.11.23 |
코딩테스트 (11/21/19) (0) | 2019.11.21 |
기초 알고리즘6(November 20 2019) (0) | 2019.11.20 |