View Code of Problem 97

#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <queue>
using namespace std;

int main()
{
	int m, n, t, flag;
	int i, j, k;
	string s[1000];
	string str[1000];
	while (cin >> n&&n!=0)
	{
		for (i = 0; i < n; i++)
			cin >> s[i];
		k = 0;
		for (i = 0; i < n; i++)
		{
			if (s[i].size() > 4)
			{
				if (s[i].substr(s[i].size() - 4, 4) == ".exe")
				{
					string t_s = s[i].erase(s[i].size() - 4, 4);
					s[i] += ".exe";
					for (j = 0; j < n; j++)
					{
						if (s[j] == t_s)
						{
							str[k++] = s[i];
							break;
						}
					}
				}
			}
			
		}
		sort(str, str + k);
		for (i = 0; i < k; i++)
			cout << str[i] << endl;
	}
	return 0;
}

Double click to view unformatted code.


Back to problem 97