2024-08-08 00:21:56
๋ฐ˜์‘ํ˜•

Up & Down game ์˜ˆ์ œ

 

1. ์ž…๋ ฅ๋ฐ›์€ number3 ์™€ ์ •๋‹ต answer๊ฐ€ ๊ฐ™์ง€ ์•Š๋‹ค๋ฉด ์„ ๊ธฐ์ค€์œผ๋กœ while๋ฌธ์„ ์‹œ์ž‘

2. ๊ฐ’์ด ๊ฐ™์ง€ ์•Š์€ ์ƒํƒœ์—์„œ ๋งŒ์•ฝ number3 > answer์ด๋ผ๋ฉด "down" ์ถœ๋ ฅ

3. ๊ฐ’์ด ๊ฐ™์ง€ ์•Š์€ ์ƒํƒœ์—์„œ ๋งŒ์•ฝ number3 < answer์ด๋ผ๋ฉด "Up" ์ถœ๋ ฅ

4. ๊ฐ’์ด ๊ฐ™์ง€ ์•Š์•„์„œ while๋ฌธ์„ ๋ชป๋น ์ ธ ๋‚˜์˜ค๋”๋ผ๋„ ๊ณ„์†ํ•ด์„œ ๋‹ต์„ ์ž…๋ ฅํ•˜๋„๋ก while๋ฌธ ์•ˆ์— ์ž…๋ ฅ๋ฉ”์†Œ๋“œ ์ž‘์„ฑ

5. ๋งŒ์•ฝ ๋‹ต์ด ๊ฐ™์œผ๋ฉด while๋ฌธ์„ ๋น ์ ธ๋‚˜์˜ค๊ณ  "์ •๋‹ต์ž…๋‹ˆ๋‹ค" ์ถœ๋ ฅ ํ›„ ์ข…๋ฃŒ

 

728x90