帮忙看看代码
  • 板块学术版
  • 楼主ZHONGWENHAO
  • 当前回复3
  • 已保存回复3
  • 发布时间2024/1/28 20:48
  • 上次更新2024/1/28 22:35:41
查看原帖
帮忙看看代码
1273492
ZHONGWENHAO楼主2024/1/28 20:48

能帮我看看这那出错了吗?

#include<bits/stdc++.h> 
using namespace std;
const int N = 1000010;

char stk[N],t = 0,n;
void push(char x){
	stk[++t] = x; 
}
void pop(){
	t--; 
}
int top(){
	return stk[t];
} 
bool stkEmpty(){
	return t==0;
} 

void stkDisplay(){
	int i = t;
	while(i!=0){
		cout<<stk[i--]<<" ";
	}
	cout<<endl; 
} 


int main() {    
	char x;
	while(cin>>x){
		push(x);
	}
	while(!stkEmpty()){
		cout<<top();
		pop();
	} 
	
	return 0;
}

输入样例:asdfghjkl123456 输出样例:654321lkjhgfdsa

2024/1/28 20:48
加载中...