C++

do-while Loop์˜ ๊ธฐ๋ณธ์ ์ธ ํ˜•ํƒœ๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™์Šต๋‹ˆ๋‹ค. // do-while Loop do { statements; } while (expression); do-while๋ฌธ์€ while๋ฌธ์—์„œ ์ฒ˜๋Ÿผ conditional expression์ด ์ถฉ์กฑ๋˜์—ˆ์„ ๋•Œ, do ๋‚ด๋ถ€์˜ statements๋ฅผ ์‹คํ–‰ํ•ฉ๋‹ˆ๋‹ค. ์—ฌ๊ธฐ์„œ ์ค‘์š”ํ•œ ์ ์€, ๋ฐ˜๋ณต๋ฌธ์„ ์‹คํ–‰ํ•œ ์ดํ›„์— ์กฐ๊ฑด๋ฌธ์„ ํ™•์ธํ•œ๋‹ค๋Š” ์ ์ž…๋‹ˆ๋‹ค. ๋‹ค์‹œ ๋งํ•˜์ž๋ฉด, ์œ„์˜ ์˜ˆ์‹œ์—์„œ statements๋ถ€๋ถ„์„ ์‹คํ–‰ํ•œ ๋’ค, expression ๋ถ€๋ถ„์„ ํ™•์ธํ•ฉ๋‹ˆ๋‹ค. ๊ทธ๋ ‡๊ธฐ ๋•Œ๋ฌธ์— do-while๋ฌธ์˜ statements๋“ค์€ ์ตœ์†Œ ํ•œ๋ฒˆ์˜ ์‹คํ–‰์ด ๋ณด์žฅ๋˜์–ด ์žˆ์Šต๋‹ˆ๋‹ค. ์˜ˆ์‹œ ์ฝ”๋“œ Example 1 // Example 1 #include using namespace std; int main(){..
Syntax // syntax while (expression) statement; // or while (expression) { statement(s); } ์ค‘์š”ํ•œ ์ ์€ infinite loop์ด ๋˜์ง€ ์•Š๋„๋ก ์‹ ๊ฒฝ์“ฐ๋Š” ๊ฒƒ์ž…๋‹ˆ๋‹ค. Example Codes // Example 1 #include using namespace std; int main(){ int i {1}; while (i
ยทC++/๊ธฐํƒ€
iomanip library๋ฅผ ํ™œ์šฉํ•˜๋ฉด ์‹ค์ˆ˜ํ˜• ์ž๋ฃŒ๋ฅผ ์ถœ๋ ฅํ•  ๋•Œ, ์†Œ์ˆ˜์  ๋ช‡๋ฒˆ์งธ ์ž๋ฆฌ์—์„œ ๋ฐ˜์˜ฌ๋ฆผ์„ ํ•  ์ง€ ๊ฒฐ์ •ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ํ˜•์‹ // FORMAT # include cout
ํ˜•์‹ // FORMAT for (var_type var_name: sequence){ statements;// can use var_name } ์˜ˆ์‹œ ์ฝ”๋“œ // Example Code #include using namespace std; int main(){ vector my_vec {10, 50, 22, 501, 1930}; for (int num:my_vec) { cout
Chan Lee
'C++' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๊ธ€ ๋ชฉ๋ก (12 Page)