2206.cpp

来自「哈尔滨工业大学ACM 竞赛网上在线试题集锦的源代码」· C++ 代码 · 共 43 行

CPP
43
字号
/*  This Code is Submitted by wywcgs for Problem 2206 on 2006-04-18 at 12:01:21 */ 
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

const int L = 128;

void expand(char*);
void suffixe(char*);

int main()
{
	char word[L];
	int t, T;
	
	scanf("%d\n", &T);
	for(t = 0; t < T; t++) { expand(gets(word)); putchar('\n'); }
	
	return 0;
}

void expand(char* str)
{
	if(!strncmp(str, "anti", 4)) { printf("against "); suffixe(str+4); }
	else if(!strncmp(str, "post", 4)) { printf("after "); suffixe(str+4); }
	else if(!strncmp(str, "pre", 3)) { printf("before "); suffixe(str+3); }
	else if(!strncmp(str, "re", 2)) { suffixe(str+2); printf(" again"); }
	else if(!strncmp(str, "un", 2)) { printf("not "); suffixe(str+2); }
	else suffixe(str);
}
void suffixe(char* str)
{
	int l = strlen(str);
	char last[5] = { str[l-1], str[l-2], str[l-3], str[l-4], 0 };
	if(!strncmp(last, "re", 2)) { str[l-2] = 0; printf("one who %ss", str); }
	else if(!strncmp(last, "gni", 3)) { str[l-3] = 0; printf("to actively %s", str); }
	else if(!strncmp(last, "ezi", 3)) { str[l-3] = 0; printf("change into %s", str); }
	else if(!strncmp(last, "s", 1)) { str[l-1] = 0; printf("multiple instances of %s", str); }
	else if(!strncmp(last, "noit", 4)) { str[l-4] = 0; printf("the process of %sing", str); }
	else printf("%s", str);
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?