#include<bits/stdc++.h> using namespace std; int main() { int n; string str; vector <string> a; vector <string > b; while(cin >> n){ if(n==0) break; getchar(); for(int i = 0; i < n; i++){ getline(cin,str); //用getline()函数为什么会出错,加了getchar才会显示,没问题 a.push_back(str); } for(int i = 0; i < n; i++){ if(a[i].find(".exe")!=-1){ for(int j = 0; j < n; j++){ if(a[j] == a[i].substr(0,a[i].size()-4)) b.push_back(a[i]); } } } sort(b.begin(),b.end()); for(int i = 0; i < b.size(); i++){ cout<< b[i] <<endl; } a.clear(); b.clear(); } return 0; } |
Double click to view unformatted code.