View Code of Problem 97

#include<string>
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
	int n;	
	while (scanf("%d", &n) != EOF && n != 0) {
		string a[1000],c[1000];
		int s = 0;
		for (int i = 0; i < n; i++) {
			cin >> a[i];
		}
		for (int i = 0; i < n; i++) {
			if (a[i].find(".exe") != -1) {
				int k = a[i].find(".exe");
				string b (a[i], 0, k);
				for (int j = 0; j < n; j++) {
					if (a[j] == b) {
						c[s++]=a[i];
						break;
					}
				}
			}
		}
		sort(c, c + s);
		for (int i = 0; i < s; i++)
		{
				cout << c[i] << endl;
		}
	}
	return 0;
}

Double click to view unformatted code.


Back to problem 97