View Code of Problem 97

#include<string>
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
	int n;
	string a[1000];
	while (scanf("%d", &n) != EOF && n != 0) {
		getchar();
		for (int i = 0; i < n; i++) {
			getline(cin, a[i]);
		}
		sort(a,a+n);
		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) {
						cout << a[i] << endl;
					}
				}
			}
		}
	}
	return 0;
}

Double click to view unformatted code.


Back to problem 97