๐ŸŒฑ → ๐ŸŒณ

[Baekjoon] 11718. ๊ทธ๋Œ€๋กœ ์ถœ๋ ฅํ•˜๊ธฐ - python ๋ณธ๋ฌธ

Algorithms

[Baekjoon] 11718. ๊ทธ๋Œ€๋กœ ์ถœ๋ ฅํ•˜๊ธฐ - python

BAY 2023. 9. 14. 09:05
728x90

https://www.acmicpc.net/problem/11718

์„ค๊ณ„ ๋ฐฉ๋ฒ•

์ž…๋ ฅ๊ฐ’์ด ๋ช‡ ๊ฐœ ์ธ์ง€ ์ฃผ์–ด์ง€์ง€ ์•Š์•˜์Œ

์ฝ”๋“œ

import sys
s = sys.stdin.readlines()
for i in s:
    print(i.rstrip())
  1. import sys์ด ๋ชจ๋“ˆ์€ Python ์‹œ์Šคํ…œ๊ณผ ๊ด€๋ จ๋œ ๊ธฐ๋Šฅ์„ ์ œ๊ณต. ์—ฌ๊ธฐ์„œ๋Š” ํ‘œ์ค€ ์ž…๋ ฅ(stdin)์„ ๋‹ค๋ฃจ๊ธฐ ์œ„ํ•ด ์‚ฌ์šฉ๋จ
  2. sys ๋ชจ๋“ˆ ์ž„ํฌํŠธ
  3. s = sys.stdin.readlines()readlines() ํ•จ์ˆ˜๋Š” ํ‘œ์ค€ ์ž…๋ ฅ์—์„œ ํ•œ ์ค„์”ฉ ์ฝ์–ด์™€์„œ ๋ฆฌ์ŠคํŠธ์— ์ถ”๊ฐ€ํ•˜๋ฉฐ, ํŒŒ์ผ์˜ ๋์— ๋„๋‹ฌํ•˜๋ฉด ๋นˆ ๋ฌธ์ž์—ด์„ ๋ฐ˜ํ™˜ํ•˜์—ฌ ๋ฐ˜๋ณต์„ ๋ฉˆ์ถค
  4. sys.stdin์„ ์‚ฌ์šฉํ•˜์—ฌ ํ‘œ์ค€ ์ž…๋ ฅ์œผ๋กœ๋ถ€ํ„ฐ ์—ฌ๋Ÿฌ ์ค„์˜ ํ…์ŠคํŠธ๋ฅผ ์ฝ์–ด์™€์„œ ๊ฐ ์ค„์„ ๋ฆฌ์ŠคํŠธ s์— ์ €์žฅ
while True :
    try :
        print(input())
    except EOFError:
        break

EOF = End Of File ์ด๋ผ๋Š” ์˜๋ฏธ์ธ๋ฐ, ๋ง ๊ทธ๋Œ€๋กœ ์ž…๋ ฅ๊ฐ’์ด ์—†์–ด์ง€๋Š” ์ƒํ™ฉ์„ ๋ฐ›์•„์คŒ

728x90