1209: 模拟出入栈游戏
#include<bits/stdc++.h>
#include <windows.h>
using namespace std;
char str[30];
stack<char> sta;
int main(){
while(scanf("%s",str+1)!=EOF){
int i=1;
for (char c = 'a'; c <= 'z'; c++) {
sta.push(c);
while (!sta.empty() && sta.top() == str[i]) {
sta.pop();
i++;
}
}
if(i==27){
printf("yes\n");
}
else
printf("no\n");
while(!sta.empty())
sta.pop();
}
}

浙公网安备 33010602011771号