poj 2538 WERTYU

简介:

简单暴力的一道题,以前做过,现在就不浪费时间自己打表了。。。

粘上一种稍微聪明的方法和一种最笨的方法。。。


聪明一些的方法:

#include <cstdio>
#include <cstring>
const char dic[]="  1234567890-=QWERTYUIOP[]\\ASDFGHJKL;'ZXCVBNM,./";
char str[1000];
int main()
{
	int i,j,l,l2=strlen(dic);
	while (gets(str)!=NULL)
	{
		l=strlen(str);
		for (i=0;i<l;i++)
		{
			for (j=1;str[i]!=dic[j] && j<l2;j++);
			if (j<l2)
				printf("%c",dic[j-1]);
			else
				printf(" ");	
		}
		printf("\n");
	}
}

最笨的方法:

#include"stdio.h"
#include"string.h"
int main()
{
	char s[100];
	char a[100]; 
	s[';'] = 'L';
	s['L'] = 'K';
	s['K'] = 'J';
	s['J'] = 'H';
	s['H'] = 'G';
	s['G'] = 'F';
	s['F'] = 'D';
	s['D'] = 'S';
	s['S'] = 'A';
	s[','] = 'M';
	s['M'] = 'N';
	s['N'] = 'B';
	s['B'] = 'V';
	s['V'] = 'C';
	s['C'] = 'X';
	s['X'] = 'Z';
	s['['] = 'P';
	s['P'] = 'O';
	s['O'] = 'I';
	s['I'] = 'U';
	s['U'] = 'Y';
	s['Y'] = 'T';
	s['T'] = 'R';
	s['R'] = 'E';
	s['E'] = 'W';
	s['W'] = 'Q';
	s['/'] = '.';
	s['\''] = ';';
	s[']'] = '[';
	s['\\'] = ']';
	s['.'] = ',';
	s['='] = '-';
	s['-'] = '0';
	s['0'] = '9';
	s['9'] = '8';
	s['8'] = '7';
	s['7'] = '6';
	s['6'] = '5';
	s['5'] = '4';
	s['4'] = '3';
	s['3'] = '2';
	s['2'] = '1';
	s['1'] = '`';
	s[' ']=' ';
	while(gets(a))
	{
		int i;
		for(i=0;i<strlen(a);i++)
			printf("%c",s[a[i]]);
		printf("\n");
	}
	return 0;
}




相关文章
|
测试技术
POJ 1001
此题用最朴素的思路实现即可,需模拟加法器,乘法器,最烦人的地方是特殊情形,如末位是小数点(12.^2=144,取小数点),整数末位是0(100^2=10000),0次幂,测试用例可能超出题目中说的范围,可能包含0次幂(100.0^0=0, 0.10^1=0.1)。
756 0
|
C语言
poj 2503 查字典
Description You have just moved from Waterloo to a big city. The people here speak an incomprehensible dialect of a foreign language.
872 0
poj 3664
http://poj.org/problem?id=3664 进行两轮选举,第一轮选前n进入第二轮,第二轮选最高   #include #include using namespace std; struct vote { int a,b; int c; ...
738 0
poj 1455
Description n participants of > sit around the table. Each minute one pair of neighbors can change their places.
622 0
poj题目分类
http://www.cnblogs.com/kuangbin/archive/2011/07/29/2120667.html
774 0
|
机器学习/深度学习
|
存储
poj 1990 MooFest
点击打开poj 1990 思路: 树状数组 分析: 1 题目给定n头牛的听力v[i]. 现在规定两头你i和j如果要进行交流的话那么消耗的能量就是dis(i,j)*max(v[i].
751 0