programming

ยทC++/๊ธฐํƒ€
ํ”„๋กœ๊ทธ๋žจ ๋‚ด์—์„œ ๋ณ€๊ฒฝ๋˜์ง€ ์•Š๊ณ  ๋ฐ˜๋ณต์ ์œผ๋กœ ์‚ฌ์šฉ๋  ๋ชฉ์ ์œผ๋กœ ์„ ์–ธ๋˜๋Š” ๊ฐ’์„ ์ƒ์ˆ˜(constant)๋ผ๊ณ  ํ•ฉ๋‹ˆ๋‹ค. ์˜ˆ๋ฅผ ๋“ค์–ด, ์ค‘๋ ฅ ๊ฐ€์†๋„ 9.80...์ด๋‚˜, ํŒŒ์ด 3.1415..., 1๋…„์— ์žˆ๋Š” ๋‹ฌ(month)์˜ ๊ฐฏ์ˆ˜ 12 ๋“ฑ์ด ์žˆ์Šต๋‹ˆ๋‹ค. c++์—์„œ ์ƒ์ˆ˜๋ฅผ ์„ ์–ธํ•˜๋Š” ๋ฐฉ๋ฒ•์€ ์—ฌ๋Ÿฌ๊ฐ€์ง€๊ฐ€ ์žˆ์ง€๋งŒ, modren C++์—์„œ ์‚ฌ์šฉ๋˜๋Š” ๋ฐฉ๋ฒ•์€ const ๋ช…๋ น์–ด ๋ฅผ ํ†ตํ•ฉ๋‹ˆ๋‹ค. ์‚ฌ์šฉ๋ฒ•์€ ๋‹ค์Œ๊ณผ ๊ฐ™์Šต๋‹ˆ๋‹ค. // ์ƒ์ˆ˜ ์„ ์–ธ: const keyword const double pi {3.141592}; const int month_in_year {12}; ์ด๋ ‡๊ฒŒ ํ•œ๋ฒˆ ์„ ์–ธ๋œ ์ƒ์ˆ˜๋Š”, ๋ณ€์ˆ˜์™€ ๋น„์Šทํ•œ ์ƒ๊น€์ƒˆ๋ฅผ ๊ฐ€์กŒ์ง€๋งŒ, ๊ทธ์™€๋Š” ๋‹ค๋ฅด๊ฒŒ ๊ฐ’์„ ์ดํ›„์— ๋ณ€๊ฒฝํ•  ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค. ์ด๋Ÿฐ ์ ์„ ์ œ์™ธํ•˜๋ฉด ๋ณ€์ˆ˜์™€ ๋™์ผํ•˜๊ฒŒ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์ฆ‰, ์ƒ์ˆ˜๋Š”..
ยทC++/๊ธฐํƒ€
c++ ์—์„œ ๊ธฐ๋ณธ์ ์ธ ์ž…์ถœ๋ ฅ ์—ฐ์‚ฐ์ž์ธ cin, cout ๋“ฑ ๋ช…๋ น์–ด๋ฅผ ์‚ฌ์šฉํ•  ๋•Œ std::cout์„ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค. ๊ทธ ์ด์œ ๋Š” ์†Œ์†์„ ๋‚˜ํƒ€๋‚ธ๋‹ค๊ณ  ํ•ด์„ํ•˜๋ฉด ํŽธ๋ฆฌํ•ฉ๋‹ˆ๋‹ค. std๊ฐ€ ์•„๋‹Œ ๋‹ค๋ฅธ namespace ์—๋„ cin, cout ๋ช…๋ น์–ด๊ฐ€ ์กด์žฌํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์ด๋Ÿฐ ๊ฒฝ์šฐ๋ฅผ ๋Œ€๋น„ํ•ด์„œ, ๋ช…๋ น์–ด ์•ž์— ์†Œ์† namespace๋ฅผ ๋ช…์‹œํ•ด์„œ ์‚ฌ์šฉํ•˜๋Š” ๊ฒƒ์ž…๋‹ˆ๋‹ค. ํ•˜์ง€๋งŒ std::๋ฅผ ๋ฐ˜๋ณตํ•˜์—ฌ ๋ถ™์ด๋Š” ๊ฒƒ์€ ๊ฝค๋‚˜ ๊ท€์ฐฎ์€ ์ผ์ด๊ธฐ์—, using namespace std; ๋ผ๋Š” ๋ช…๋ น์–ด๋ฅผ ํฌํ•จํ•˜์—ฌ std๋ฅผ ์ƒ๋žตํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ๊ฐ€๋ น ๋‹ค์Œ๊ณผ ๊ฐ™์€ ์ฝ”๋“œ๊ฐ€ ์žˆ๋‹ค๋ฉด, #include int main(){ std::cout
ยทpython
https://www.acmicpc.net/problem/2563 2563๋ฒˆ: ์ƒ‰์ข…์ด ๊ฐ€๋กœ, ์„ธ๋กœ์˜ ํฌ๊ธฐ๊ฐ€ ๊ฐ๊ฐ 100์ธ ์ •์‚ฌ๊ฐํ˜• ๋ชจ์–‘์˜ ํฐ์ƒ‰ ๋„ํ™”์ง€๊ฐ€ ์žˆ๋‹ค. ์ด ๋„ํ™”์ง€ ์œ„์— ๊ฐ€๋กœ, ์„ธ๋กœ์˜ ํฌ๊ธฐ๊ฐ€ ๊ฐ๊ฐ 10์ธ ์ •์‚ฌ๊ฐํ˜• ๋ชจ์–‘์˜ ๊ฒ€์€์ƒ‰ ์ƒ‰์ข…์ด๋ฅผ ์ƒ‰์ข…์ด์˜ ๋ณ€๊ณผ ๋„ํ™”์ง€์˜ ๋ณ€์ด ํ‰ํ–‰ํ•˜๋„๋ก www.acmicpc.net ์ฝ”๋“œ paper_list = [[0 for i in range(100)] for j in range(100)] times = int(input()) for _ in range(times): x, y = map(int, input().split()) for row in range(x, x+10): for col in range(y, y+10): paper_list[row][col] = 1 result ..
ยทpython
https://www.acmicpc.net/problem/10789 10789๋ฒˆ: ๊ฐ€์ƒ ํ‚ค๋ณด๋“œ ์ž…๋ ฅ ์ž…๋ ฅ์˜ ์ฒซ ๋ฒˆ์งธ ์ค„(ํ–‰)์—๋Š” ๋‘ ๊ฐœ์˜ ์ •์ˆ˜ r๊ณผ c (1 ≤ r, c ≤ 50)๊ฐ€ ํฌํ•จ๋˜์–ด ๊ฐ€์ƒ ํ‚ค๋ณด๋“œ ๊ฒฉ์ž์˜ ํ–‰๊ณผ ์—ด ์ˆ˜๋ฅผ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค. ๊ฐ€์ƒ ํ‚ค๋ณด๋“œ๋Š” ๋‹ค์Œ r ํ–‰์— ํ‘œ์‹œ๋˜๋ฉฐ ๊ฐ ํ–‰์—๋Š” c ๋ฌธ์ž๊ฐ€ ๋“ค์–ด ์žˆ์Šต๋‹ˆ๋‹ค. www.acmicpc.net ์ฝ”๋“œ my_list = [] for _ in range(5): my_list.append(list(input())) for row in range(15): for col in range(5): try: print(my_list[col][row], end="") except: continue ์„ค๋ช… 1. my_list์— ์ž…๋ ฅ๊ฐ’์„ ํ•œ์ค„ ์”ฉ list๋กœ ๋ณ€ํ™˜ํ•˜์—ฌ ์ €์žฅํ•œ๋‹ค. (2..
Chan Lee
'programming' ํƒœ๊ทธ์˜ ๊ธ€ ๋ชฉ๋ก (4 Page)