스택 값이 이상하게 나와요 ;;
설희
2023.04.01
#include stdio.h
char stack[30];
int bottom=0;
void push(int k)
{
stack[bottom]=k;
bottom++;
}
void pop()
{
bottom--;
}
void show()
{
int i;
for (i=0; ibottom; i++)
printf(%d,stack[i]);
printf(\n);
}
void main()
{
push(30);
show();
push(70);
show();
push(20);
show();
pop();
show();
}#include iostream
using namespace std;
char stack[30];
int bottom=0;
void push(int k)
{
stack[bottom]=k;
bottom++;
}
void pop()
{
bottom--;
}
void show()
{
int i;
for (i=0; ibottom; i++)
cout stack[i] \n;
}
void main()
{
push(30);
show();
push(70);
show();
push(20);
show();
pop();
show();
}위에껀 값이 정상적으로 나오는데요..
아래껀 뭐가 잘못된건가요?
값이 이상하게 나와요... 킁..
-
꽃내
출력부분에서 cout(int)stack[i]\\\n\;으로 고쳐보세요 즐플하세요~~ : )