ํœด์ง€ํ†ต

[Python] ์˜ค๋Š˜์˜ ๋ฐฑ์ค€ 10818, 2562๋ฒˆ ์ •๋‹ต

์ฑ„๋ฏœ 2021. 10. 22.
728x90
๋ฐ˜์‘ํ˜•

๋ฐฑ์ค€ 10818๋ฒˆ

#10818 ๋‚ด์žฅํ•จ์ˆ˜๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ๊ฒฝ์šฐ

count = int(input())
nums = list(map(int, input().split()))
print(max(nums), min(nums))


#10818 ๋‚ด์žฅํ•จ์ˆ˜ ์‚ฌ์šฉ ์•ˆํ•˜๋Š” ๊ฒฝ์šฐ

count = int(input())
nums = list(map(int, input().split()))

max = nums[0]
min = nums[0]

for i in nums[1:]:
  if i>max:
    max = i
  elif i<min:
    min = i

print(max, min)

๋‚œ์ด๋„: โ˜…โ˜…โ˜†โ˜†โ˜†

<list(map(int, input().split())) : ํ•œ๋ฒˆ์— ์—ฌ๋Ÿฌ๊ฐœ ์ž…๋ ฅ>๊ธฐ์–ตํ•˜๊ธฐ!

 

๋ฐฑ์ค€ 2562๋ฒˆ

#2562

lst = []

for i in range(9):
  n = int(input())  #lst.append(int(iput()))์œผ๋กœ ์ค„์ผ ์ˆ˜ ์žˆ๋‹ค. 
  lst.append(n)

max = 0

for i in lst:
  if max<i:
    max = i
    cnt = lst.index(i)+1 #lst์—์„œ i์ผ๋•Œ ์ธ๋ฑ์Šค๊ฐ’+1

print(max)
print(cnt)

๋‚œ์ด๋„: โ˜…โ˜…โ˜…โ˜†โ˜†

๊ณ„์† ๋Ÿฐํƒ€์ž„ ์—๋Ÿฌ๊ฐ€ ๋‚ฌ๋‹ค.

๋ฆฌ์ŠคํŠธ์˜ ์ธ๋ฑ์Šค๊ฐ’์€ lst.index(i)!!

์žŠ์ง€๋ง์ž

 

๋ฐ˜์‘ํ˜•

๋Œ“๊ธ€

๐Ÿ’ฒ ์ถ”์ฒœ ๊ธ€