f0606.cpp
资源名称:c.rar [点击查看]
上传用户:puke2000
上传日期:2022-07-25
资源大小:912k
文件大小:1k
源码类别:
C#编程
开发平台:
Visual C++
- //==================================
- // f0606.cpp
- // 安排车厢顺序栈版本
- //==================================
- #include<fstream>
- #include<iostream>
- #include<sstream>
- #include<stack>
- using namespace std;
- //----------------------------------
- int main(){
- ifstream in("rail.txt");
- for(int n,line=0; in>>n && n && in.ignore(); ){
- cout<<(line++ ? "n":"");
- for(string s; getline(in, s) && s!="0"; ){
- istringstream sin(s);
- stack<int> st;
- for(int last=0,coach; sin>>coach; st.pop()){
- for(int p=last+1; p<=coach; ++p) st.push(p);
- if(last<coach) last=coach;
- if(st.top()!=coach) break;
- }
- cout<<(!sin ? "Yesn" : "Non");
- }
- }
- }//=================================