Hello Ocean! ๐ŸŒผ

[C++] ๋ฐฐ์—ด ๋ฉ”๋ชจ๋ฆฌ ์ดˆ๊ธฐํ™” ๋ณธ๋ฌธ

Algorithm

[C++] ๋ฐฐ์—ด ๋ฉ”๋ชจ๋ฆฌ ์ดˆ๊ธฐํ™”

bba_dda 2020. 4. 11. 11:28
๋ฐ˜์‘ํ˜•

1. memset()

- ์•Œ๊ณ ๋ฆฌ์ฆ˜ ๋ฌธ์ œ ํ•ด๊ฒฐ ์ „๋žต ์ฑ…์—์„œ ์ด ๋ฐฉ๋ฒ•์„ ์‚ฌ์šฉํ•˜์˜€๋‹ค. 

memset(arr,value,size) ์™€ ๊ฐ™์ด ์‚ฌ์šฉํ•œ๋‹ค.

 

์ด ๋ฐฉ๋ฒ•์€ vs์—์„œ๋Š” ํ—ค๋”ํŒŒ์ผ ์—†์ด ์ž˜ ์‹คํ–‰๋˜์ง€๋งŒ, ๋ฐฑ์ค€์— ์ œ์ถœํ•  ๋•Œ ์ถ”๊ฐ€์ ์œผ๋กœ memory.h๋ฅผ includeํ•ด์ค˜์•ผ ํ•˜๋Š” ๋ฒˆ๊ฑฐ๋กœ์›€์ด ์žˆ๋‹ค. 

 

2. fill(), fill_n()

- memset๋Œ€์‹  ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋‹ค๊ณ  ์นœ๊ตฌ๊ฐ€ ์•Œ๋ ค์คฌ๋‹ค.

https://namwhis.tistory.com/entry/C-%EB%B0%B0%EC%97%B4-%EC%B4%88%EA%B8%B0%ED%99%94-stdfill-stdfilln-%EC%A0%95%EB%A6%AC

 

C++ ๋ฐฐ์—ด ์ดˆ๊ธฐํ™” std::fill, std::fill_n .. ์ •๋ฆฌ

BAEKJOON ONLINE JUDGE๋ฅผ ์‹œ์ž‘ํ•˜๊ฒŒ ๋œ ๊ณ„๊ธฐ๊ฐ€ C++๊ณผ ์นœํ•ด์ง€์ž์˜€์Šต๋‹ˆ๋‹ค. ์ง€๊ธˆ์€ ๋งŽ์ด ์นœํ•ด์กŒ์Šต๋‹ˆ๋‹ค๋งŒ ์˜๋ฏธ๋ฅผ ์ž˜ ๋ชจ๋ฅด๊ณ , ํ˜น์€ ์ž˜๋ชป ์•Œ๊ณ  ์Šต๊ด€์ ์œผ๋กœ ์“ฐ๋Š” ๊ฒƒ๋“ค์ด ์žˆ๋„ค์š”. ๊ทธ ์ค‘ ํ•˜๋‚˜๊ฐ€ ๋ฐฐ์—ด ์ดˆ๊ธฐํ™” ์ž…๋‹ˆ๋‹ค. ํ‹€๋ฆฌ๊ณ ..

namwhis.tistory.com

์ด ๋งํฌ์— ์ •๋ฆฌ๊ฐ€ ์ž˜ ๋˜์–ด์žˆ์–ด์„œ ์ฐธ๊ณ ํ•ด์„œ ๊ณต๋ถ€ํ–ˆ๋‹ค. 

๋ฐ˜์‘ํ˜•