๐Ÿ’ป Dev & CSC++ Programming

C++ Programming Ch.11 Exercise 1 Solution

Problem: int cin.get() ํ•จ์ˆ˜๋ฅผ ์ด์šฉํ•˜์—ฌ ํ‚ค๋ณด๋“œ๋กœ๋ถ€ํ„ฐ ํ•œ ๋ผ์ธ์„ ์ฝ๊ณ  'a'๊ฐ€ ๋ช‡ ๊ฐœ์ธ์ง€ ์ถœ๋ ฅํ•˜๋Š” ํ”„๋กœ๊ทธ๋žจ์„ ์ž‘์„ฑํ•˜๋ผ. Execution Result: Objective & Hints: cin์œผ๋กœ ํ‚ค ์ž…๋ ฅ ์—ฐ์Šต Code: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 #include using namespace std; int main() { int a; int cnt=0; while( (a = cin.get() ) != EOF ){ if(a == 'a') cnt++; else if(a == '\n') break; } cout << cnt; } Explanation: ...

March 27, 2020 ยท 1 min ยท Sobamemil