⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 2395.cpp

📁 这是哈尔滨工业大学acmOJ的源代码
💻 CPP
字号:
/* This Code is Submitted by wywcgs for Problem 2395 on 2006-10-10 at 16:11:13 */
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

const int N = 128;

int main()
{
	char w[N];
	bool g[N];
	
	
	memset(g, false, sizeof(g));
	g['K'] = g['N'] = g['A'] = g['C'] = g['E'] = g['p'] = g['q'] = g['r'] = g['s'] = g['t'] = true;
	while(gets(w) != NULL && strcmp(w, "0")) {
		int len = strlen(w);
		sort(w, w+len);
		int u = 0, d = 0;
		for(int i = 0; w[i] != 0; i++)
			if(!g[w[i]]) continue;
			else if(isupper(w[i]) && w[i] != 'N') u++;
			else if(islower(w[i])) d++;
		int n = min(u+1, d); u = n-1; d = n;
		if(n < 1) { printf("no WFF possible\n"); continue; }
		for(int i = 0, cu = 0, cd = 0; w[i] != 0; i++)
			if(!g[w[i]]) continue;
			else if(n != 0 && w[i] == 'N') putchar('N');
			else if(isupper(w[i])) {
				if(cu >= u) continue;
				putchar(w[i]); cu++;
			} else if(islower(w[i])) {
				if(cd >= d) continue;
				putchar(w[i]); cd++;
			}
		putchar('\n');
	}
	
	return 0;
}

⌨️ 快捷键说明

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