๐Ÿ’ป Dev & CSC++ Programming

C++ Programming Ch.2 Exercise 13 Solution

Problem: ์ค‘์‹๋‹น์˜ ์ฃผ๋ฌธ ๊ณผ์ •์„ C++ ํ”„๋กœ๊ทธ๋žจ์œผ๋กœ ์ž‘์„ฑํ•ด๋ณด์ž. ๋‹ค์Œ Execution Result์™€ ๊ฐ™์ด ๋ฉ”๋‰ด์™€ ์‚ฌ๋žŒ ์ˆ˜๋ฅผ ์ž…๋ ฅ๋ฐ›๊ณ  ์ด๋ฅผ ์ถœ๋ ฅํ•˜๋ฉด ๋œ๋‹ค. ์ž˜๋ชป๋œ ์ž…๋ ฅ์„ ๊ฐ€๋ ค๋‚ด๋Š” ๋ถ€๋ถ„๋„ ์ฝ”๋“œ์— ์ถ”๊ฐ€ํ•˜๋ผ. Objective & Hints: C++ ํ”„๋กœ๊ทธ๋žจ์œผ๋กœ ๊ตฌ์„ฑ, ํ‚ค ์ž…๋ ฅ ๋“ฑ ์ข…ํ•ฉ ์—ฐ์Šต Execution Result: Code: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 #include using namespace std; int main() { int num,tot; cout << "***** ์Šน๋ฆฌ์žฅ์— ์˜ค์‹  ๊ฒƒ์„ ํ™˜์˜ํ•ฉ๋‹ˆ๋‹ค. ***** \n"; while(true){ cout << "์งฌ๋ฝ•:1, ์งœ์žฅ:2, ๊ตฐ๋งŒ๋‘:3, ์ข…๋ฃŒ:4>> "; cin >> num; if(num == 4) { cout << "์˜ค๋Š˜ ์˜์—…์€ ๋๋‚ฌ์Šต๋‹ˆ๋‹ค."; break; } if(num > 4) { cout << "๋‹ค์‹œ ์ฃผ๋ฌธํ•˜์„ธ์š”!!\n"; continue; } cout << "๋ช‡์ธ๋ถ„?"; cin >> tot; if(num==1) cout << "์งฌ๋ฝ• " << tot << "์ธ๋ถ„ ๋‚˜์™”์Šต๋‹ˆ๋‹ค\n"; else if(num==2) cout << "์งœ์žฅ " << tot << "์ธ๋ถ„ ๋‚˜์™”์Šต๋‹ˆ๋‹ค\n"; else if(num==3) cout << "๊ตฐ๋งŒ๋‘ " << tot << "์ธ๋ถ„ ๋‚˜์™”์Šต๋‹ˆ๋‹ค\n"; } return 0; } Explanation: ...

February 28, 2020 ยท 1 min ยท Sobamemil