๋ฌธ์
์ ์ ์์๋ฅผ ์ ์ฅํ๋ stack์ class๋ฅผ ์ฌ์ฉํ์ฌ ๊ตฌํํ๊ณ , ์ด๋ฅผ ์ด์ฉํ์ฌ, ์ฃผ์ด์ง array์ ์ ์ ์์ n๊ฐ ์์ 100๋ณด๋ค
ํฐ ๊ฐ์ ์ญ์์ผ๋ก ์ถ๋ ฅํ๋ ํ๋ก๊ทธ๋จ์ ์์ฑํ์์ค. (๋ค์ main() ํจ์๊ฐ ๋์ํ๋๋ก ๋๋จธ์ง ๋ถ๋ถ์ ์์ฑ)
int main()
{
mystack s1;
int list[5] = { 32, 123, 27, 131, 242 }, i, x;
s1.init();
for (i = 0; i < 5; i++ )
if (list[i]> 100)
s1.push( list[i] );
while ( ! s1.stack_empty( ) )
{
x = s1.pop( );
cout << x << endl ;
}
return 0;
}
๋ฌธ์ ํฌ์ธํธ
1) ์กฐ๊ฑด์ ๋ง๊ฒ ์คํ์ ํธ์๋ฅผ ํ ์ ์๋๊ฐ
2) ์กฐ๊ฑด์ ๋ง๊ฒ ์คํ์์ ํ์ ํ ์ ์๋๊ฐ
3) stack class๋ฅผ ๊ตฌํํ ์ ์๋๊ฐ
4) stack์ adt๋ฅผ ์ดํดํ๋๊ฐ
'๋ฌธ์ ํ์ด๐ฉ๐ปโ๐ป' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[c++] Infix expression์ Postfix expression์ผ๋ก ๋ณํํ๊ธฐ (0) | 2023.09.24 |
---|