View Code of Problem 97

#include <cstdio>
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;

int main(){
	int t;
	while(cin>>t){
		if(t==0)
			break;
		string s[1001];
		string cmp[1001]; 
		for(int i=0;i<t;i++){
			string name;
			cin>>name;
			s[i]=name;
		}
		int count=0;
		for(int i=0;i<t;i++){
			string kk=s[i];
			
			int n=kk.length();
			if(n>=4){
				string wei=kk.substr(n-4,4);
				if(wei==".exe"){
					string head=kk.substr(0,n-4);
					for(int j=0;j<t;j++){
						if(s[j]==head){
							cmp[count]=kk;
							count++;
						}
					}
				}
			}
			
		}
		sort(cmp,cmp+count);
		for(int i=0;i<count;i++){
			cout<<cmp[i]<<endl;
		}
	}
}

Double click to view unformatted code.


Back to problem 97