536 : 반복제어문1 - 자가진단1

i = 1
p = ""
while i <= 15:
  #print(i, end=" ")
  p += str(i) + " "
  i += 1
print(p)
i = 1
while i <= 15:
  print(i, end=" ")
  i += 1
for i in range(1, 16):
  print(i, end = " ")

537 : 반복제어문1 - 자가진단2

 

n = int(input())
sum = 0
i = 1
while i <= n:
  sum += i
  i +=1;

print(sum)
n = int(input())
sum = 0
for i in range(1, n+1):
  sum += i

print(sum)

538 : 반복제어문1 - 자가진단3

while True:
  a = int(input())
  if a == 0:
    break
  if a > 0:
    print("Pos")
  else:
    print("Neg")

539 : 반복제어문1 - 자가진단4

#입력을 한줄에 한개씩 받아야 함.
cnt = 0
sum = 0
while True:
  a = int(input())
  sum += a
  cnt += 1
  if a >= 100:
    break

print("%d %d \n%.1f" %(sum,cnt, sum/cnt))
n = list(map(int, input().split()))
cnt = 0
sum = 0
for a in n:
  sum += a
  cnt += 1
  if a >= 100:
    break

print("%d %d \n%.1f" %(sum,cnt, sum/cnt))

540 : 반복제어문1 - 자가진단5

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

633 : 반복제어문1 - 자가진단6

while True:
  print("1. Korea\n2. USA\n3. Japan\n4. China\nnumber?", end = " ")
  a = int(input())
  if a == 1:
    print("\nSeoul\n")
  elif a == 2:
    print("\nWashington\n")
  elif a == 3:
    print("\nBeijing\n")
  else : 
    print("\nnone\n")
    break

125 : 반복제어문1 - 형성평가1

a = int(input())
i = 1
while i<=a:
  print(i, end=" ")
  i += 1
a = int(input())
for i in range(1, a+1):
  print(i, end=" ")

126 : 반복제어문1 - 형성평가2

odd = 0
even = 0
while True:
  a = int(input())
  if a == 0:
    break
  if a%2 == 0:
    even += 1
  else:
    odd +=1
  
print("odd : %d\neven : %d" %(odd, even) )
n = list(map(int, input().split()))
odd = 0
even = 0
for a in n:
  if a == 0:
    break
  if a%2 == 0:
    even += 1
  else:
    odd +=1
  
print("odd : %d\neven : %d" %(odd, even) )

127 : 반복제어문1 - 형성평가3

sum = 0
cnt = 0
while True:
  a = int(input())
  if a < 0 or a > 100:
    break
  sum += a
  cnt += 1

print("sum : %d\navg : %.1f" %(sum, sum/cnt))
n = list(map(int, input().split()))
sum = 0
cnt = 0
for a in n:
  if a < 0 or a > 100:
    break
  sum += a
  cnt += 1

print("sum : %d\navg : %.1f" %(sum, sum/cnt))

128 : 반복제어문1 - 형성평가4

n = list(map(int, input().split()))
cnt = 0

for a in n:
  if a%3 != 0 and a%5 != 0:
    cnt += 1

print(cnt)

129 : 반복제어문1 - 형성평가5

 

while True:
  b = int(input("Base = "))
  h = int(input("Height = "))
  area = b*h/2
  print("Triangle width = %.1f" %area)
  y = input("Continue? ")
  if(y != 'y' and y != 'Y'):
    break

 

'정보올림피아드-KOI > 기초 문법 문제' 카테고리의 다른 글

반복제어문3  (0) 2020.12.29
반복제어문2  (0) 2020.12.29
182 : 문자열1 - 형성평가1  (0) 2020.04.04
184 : 문자열1 - 형성평가3  (0) 2020.04.04
185 : 문자열1 - 형성평가4  (0) 2020.04.04

+ Recent posts