View Code of Problem 97

#include<iostream>
#include<cstdio>
#include<algorithm>

using namespace std;
string s[1005], ans[600];

int main()
{
	int n;
	while(scanf("%d", &n) != EOF)
	{
		int k = 0;
		if(n == 0)
			break;
		for(int i = 0; i < n ; i++)
			cin >> s[i];
		for(int i = 0; i < n; i++)
		{
			int pos = -1;
			pos = s[i].find(".exe");
			if(pos != -1)
			{
				string str = s[i].substr(0, s[i].length() - 4);
				for(int j = 0; j < n; j++)
					if(s[j] == str)
					{
						ans[k++] = s[i];
						break;
					}
			}
		}
		sort(ans, ans + k);
		for(int i = 0; i < k; i++)
			cout << ans[i] << endl;
	}
	return 0;
}

Double click to view unformatted code.


Back to problem 97