#include #include #include #include #include #include using namespace std; string a,b;//不能用vector,否则还要设置新变量,再一个一个用push_back输入 int n; int main() { while(cin >> n >> a >> b) { stack Train;//不要再次设成全局了 vector mark;//用来表示进入和输出0进1出; int j = 0,k = 0;//j用来表示mark中的下标,k用来表示 b中的下标 for(int i = 0;i < n;i++) { Train.push(a[i]); mark.push_back(0);//0代表进in j++; while(!Train.empty() && Train.top() == b[k]) { Train.pop(); mark.push_back(1); j++; k++; } } if(Train.empty()) { cout << "Yes." << endl; for(int i = 0;i < j;i++) { if(mark[i]) cout << "out" << endl; else cout << "in" << endl; } } else cout << "No." << endl; cout << "FINISH" << endl; } return 0; }
太难受了,写代码30分钟,找bug两个小时,bug竟然只是把stack Train;vector mark;定义在了全局,,devc++有没有调试窗口。。。。。(或者以后接着用vs)
上一篇 [问答题 简答题] 公共信道信令主要优点有哪些?
下一篇 C++构造函数
版权所有 (c)2021-2022 MSHXW.COM
ICP备案号:晋ICP备2021003244-6号