www.acmicpc.net/step/4

 

 

 

 

 

1. 두 수 비교하기 (#1330번)

 

A,B = map(int, input().split())

if A>B :
    print('>')
elif A<B :
    print('<')
else :
    print('==')

 

혹은 삼항 연산자 코드

A,B = map(int, input().split())

print ('>') if A>B else print('<') if A<B else print('==')

 

 

 


 

 

 

2. 시험 성적 (#9498번)

 

result = int(input())

if result >=90:
    print('A')
elif result >=80:
    print('B')
elif result >=70:
    print('C')
elif result >=60:
    print('D')
else :
    print('F')

 

 

 


 

 

 

3. 윤년 (#2753번)

 

year = int(input)

if ((year%4 == 0) and (year%4 != 0)) or (year%100 ==0):
    print('1')
else:
    print('0')


삼항 연산자
year = int(input())
print('1') if (( year&4 == 0) and ( year&100 != 0 )) or ( year%400 == 0) else print('0')

 

 

 


 

 

 

4. 사분면 고르기 (#14681번)

 

x = int(input())
y = int(input())

if x > 0 and y > 0:
    print('1')
elif x < 0 and y > 0 :
    print('2')
elif x < 0 and y < 0 :
    print('3')
else:
    print('4')

 

 

 


 

 

 

5. 알람 시계 (#2884번)

 

H, M = map(int, input().split())

if M >= 45 :
    print(H, M-45)
elif M < 45 :
    if H == 0:
        print('23', M+15)
    else :
        print(H-1, M+15)

 

728x90
반응형

+ Recent posts