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();
	}
}
posted @ 2026-03-17 11:29  peter_shen  阅读(2)  评论(0)    收藏  举报