ACM (TJU) : 2911


#include <iostream>
#include <string>
using namespace std;

void call (string s) 
{
	int length = s.length ();
	int i;

	if ( s [length - 1] == 'y' && !(s [length - 2] == 'a' || s [length - 2] == 'e' || s [length - 2] == 'i' || s [length - 2] == 'o' || s [length - 2] == 'u') ) {
		for ( i = 0; i < length - 1; i++ )
			cout << s [i];
		cout << "ies" << endl;
	}

	else if ( s [length - 1] == 'o' || s [length - 1] == 's' || s [length - 1] == 'x'  )
		cout << s << "es" << endl;

	else if ( s [length - 1] == 'h' && ( s [length - 2] == 'c' || s [length - 2] == 's' ))
		cout << s << "es" << endl;

	else
		cout << s << "s" << endl;
}

int main ()
{
	int l, n;
	cin >> l >> n;

	string singular [22];
	string plural [22];

	int i;
	for ( i = 0; i < l; i++ )
		cin >> singular [i] >> plural [i];

	string s;
	for ( i = 0; i < n; i++ ) {
		
		cin >> s;
		bool flag = true;
		
		for ( int j = 0; j < l; j++ ) {
			if ( s == singular [j] ) {
				cout << plural [j] << endl;
				flag = false;
			}
		}

		if ( flag )
			call (s);
	}

	return 0;
}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s