UVa 11233 - Deli Deli

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

分析:模拟。直接按章题意分情况求解即可。

说明:按语法也可以(⊙_⊙)。

#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;
}
时间: 2024-08-10 15:40:42

UVa 11233 - Deli Deli的相关文章

HDU 1804:Deli Deli

Deli Deli Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 1708    Accepted Submission(s): 942 Problem Description Mrs. Deli is running the delicatessen store "Deli Deli". Last year Mrs. De

杭电ACM分类

杭电ACM分类: 1001 整数求和 水题1002 C语言实验题——两个数比较 水题1003 1.2.3.4.5... 简单题1004 渊子赛马 排序+贪心的方法归并1005 Hero In Maze 广度搜索1006 Redraiment猜想 数论:容斥定理1007 童年生活二三事 递推题1008 University 简单hash1009 目标柏林 简单模拟题1010 Rails 模拟题(堆栈)1011 Box of Bricks 简单题1012 IMMEDIATE DECODABILITY

【转】对于杭电OJ题目的分类

[好像博客园不能直接转载,所以我复制过来了..] 1001 整数求和 水题1002 C语言实验题——两个数比较 水题1003 1.2.3.4.5... 简单题1004 渊子赛马 排序+贪心的方法归并1005 Hero In Maze 广度搜索1006 Redraiment猜想 数论:容斥定理1007 童年生活二三事 递推题1008 University 简单hash1009 目标柏林 简单模拟题1010 Rails 模拟题(堆栈)1011 Box of Bricks 简单题1012 IMMEDI

转载:hdu 题目分类 (侵删)

转载:from http://blog.csdn.net/qq_28236309/article/details/47818349 基础题:1000.1001.1004.1005.1008.1012.1013.1014.1017.1019.1021.1028.1029. 1032.1037.1040.1048.1056.1058.1061.1070.1076.1089.1090.1091.1092.1093. 1094.1095.1096.1097.1098.1106.1108.1157.116

[转]The culture name list in C#

Culture Names [C#] This example shows how to get all culture names in the .NET Framework. Use static methodCultureInfo.Get­Cultures. To get associated specific culture use static method CultureInfo.Cre­ateSpecificCul­ture. Following code is modified

UVA 562 Dividing coins --01背包的变形

01背包的变形. 先算出硬币面值的总和,然后此题变成求背包容量为V=sum/2时,能装的最多的硬币,然后将剩余的面值和它相减取一个绝对值就是最小的差值. 代码: #include <iostream> #include <cstdio> #include <cstring> #include <cmath> #include <algorithm> using namespace std; #define N 50007 int c[102],d

UVA 10341 Solve It

Problem F Solve It Input: standard input Output: standard output Time Limit: 1 second Memory Limit: 32 MB Solve the equation: p*e-x + q*sin(x) + r*cos(x) + s*tan(x) + t*x2 + u = 0 where 0 <= x <= 1. Input Input consists of multiple test cases and te

UVA 11014 - Make a Crystal(容斥原理)

UVA 11014 - Make a Crystal 题目链接 题意:给定一个NxNxN的正方体,求出最多能选几个整数点.使得随意两点PQ不会使PQO共线. 思路:利用容斥原理,设f(k)为点(x, y, z)三点都为k的倍数的点的个数(要扣掉一个原点O).那么全部点就是f(1),之后要去除掉共线的,就是扣掉f(2), f(3), f(5)..f(n).n为素数.由于这些素数中包括了合数的情况,而且这些点必定与f(1)除去这些点以外的点共线,所以扣掉.可是扣掉后会扣掉一些反复的.比方f(6)在f

[UVa] Palindromes(401)

UVA - 401 Palindromes Time Limit: 3000MS   Memory Limit: Unknown   64bit IO Format: %lld & %llu Submit Status Description A regular palindrome is a string of numbers or letters that is the same forward as backward. For example, the string "ABCDED