Programming/JUNGOL : 정보올림피아드&알고리즘

[JUNGOL LCoder_Python 반복제어문]:821~831

토토모에요 2022. 1. 26. 17:22
728x90
반응형

JUNGOL 정보올림피아드&알고리즘에서 학습용으로 문제를 가져왔습니다. 문제가 될 시 수정, 삭제하겠습니다.

http://www.jungol.co.kr/

821

for i in range(1,16):
    print(i,end=" ")

822

sum=0
a=int(input())
while True:
    sum+=a
    a -= 1
    if a==0:
        break
print(sum)

823

while True:
    a=int(input("number? "))
    if a==0:
        break
    elif a>0:
        print("positive integer")
    elif a<0:
        print("negative number")

824

sum=0
num=0
while True:
    a=int(input())
    sum+=a
    num+=1
    if a>=100:
        break
print(sum)
print("%.1f" %(sum/num))

825

while True:
    a = int(input())
    if a%3==0:
        print(a//3)
    elif a==-1:
        break

826

lst=["Seoul","Washington","Tokyo","Beijing"]
while True:

    print("""1. Korea                   
2. USA
3. Japan
4. China""")
    a=input("number? ")

    if 0<int(a)<=len(lst):
        print(lst[int(a) - 1])

    else:
        print("none")
        break

827

a=int(input())
i=1
while True:
    print(i,end=" ")
    i+=1
    if i==a:
        print(i, end=" ")
        break

828

odd=0
even=0
while True:
    a=int(input())
    if a==0:
        break
    else:
        if a%2==1:
            odd+=1
        elif a%2==0:
            even+=1

print("odd : %d"%odd)
print("even : %d"%even)

829

total=0
num=0
while True:
    a=int(input())
    if a<0 or a>100:
        break
    else:
        total += a
        num += 1
print("sum : %d"%total)
print("avg : %.1f"%(total/num))

830

b=[]
while True:
    a=int(input())
    if a==0:
        break
    elif a%3==0 or a%5==0:
        pass
    else:
        b.append(a)

print(len(b))

831

while True:
    a=int(input("Width = "))
    b=int(input("Height = "))
    print("Triangle Area = %.1f"%(a*b/2))
    d=input("Continue? ")
    if d=="Y" or d=="y":
        pass
    else:
        break
반응형