UVa 11233

题目:求所给单词的负数形式。

分析:模拟。

直接按章题意分情况求解就可以。

说明:按语法也能够(⊙_⊙)。

#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>

using namespace std;

char word[22][22],maps[22][22],text[25];

int cmp(char *s, char c)
{
	for (int i = 0 ; s[i] ; ++ i)
		if (s[i] == c)
			return 1;
	return 0;
}

int main()
{
	int L,N;
	while (cin >> L >> N) {
		for (int i = 0 ; i < L ; ++ i)
			cin >> word[i] >> maps[i];
		for (int i = 0 ; i < N ; ++ i) {
			cin >> text;
			int flag = 0;
			for (int j = 0 ; j < L ; ++ j)
				if (!strcmp(text,word[j])) {
					cout << maps[j] << endl;
					flag = 1;
					break;
				}
			if (flag) continue;
			int end = strlen(text)-1;
			if (end > 0 && text[end] == 'y' && !cmp("aeiou", text[end-1])) {
				strcpy(&text[end],"ies");
				cout << text << endl;
			}else if (cmp("osx", text[end]))
				cout << text << "es" << endl;
			else if (end > 0 && text[end] == 'h' && cmp("cs", text[end-1]))
				cout << text << "es" << endl;
			else cout << text << "s" << endl;
		}
	}
	return 0;
}

原文地址:https://www.cnblogs.com/blfshiye/p/5070400.html