f0607.cpp
资源名称:c.rar [点击查看]
上传用户:puke2000
上传日期:2022-07-25
资源大小:912k
文件大小:1k
源码类别:
C#编程
开发平台:
Visual C++
- //==================================
- // f0607.cpp
- // 安排车厢顺序向量版
- //==================================
- #include<fstream>
- #include<iostream>
- #include<sstream>
- #include<vector>
- 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);
- vector<int> st;
- for(int last=0,coach; sin>>coach; st.erase(st.begin())){
- for(int p=last+1; p<=coach; ++p) st.insert(st.begin(),p);
- if(last<coach) last=coach;
- if(st.front()!=coach) break;
- }
- cout<<(!sin ? "Yesn" : "Non");
- }
- }
- }//=================================