UVA10082

A common typing error is to place the hands on the keyboard one row to the right of the correct position. So “Q” is typed as “W” and “J” is typed as “K” and so on. You are to decode a message typed in this manner.

Input consists of several lines of text. Each line may contain digits, spaces, upper case letters (except Q, A, Z), or punctuation shown above [except back-quote (`)]. Keys labelled with words [Tab, BackSp, Control,etc.] are not represented in the input. You are to replace each letter or punction symbol by the one immediately to its left on the QWERTY keyboard shown above. Spaces in the input should be echoed in the output.

Sample Input

O S, GOMR YPFSU/

Output for Sample Input

I AM FINE TODAY.

思路:emmmm先把这些东西存到一个数组里面从第一个开始一直存到最后面 其中自己忽略了\\这个东西 出现\这个东西直接输出

还有自己输出while((ch=getchar())!=EOF)都忘记了  无语

代码:

#include<bits/stdc++.h>
using namespace std;
const int size=11;
int main()
{
	char str[15];
	gets(str);//读取第一行的___
	int num[15]={0,0,64,32,16,8,0,4,2,1,0};//| oo o.ooo|
	while(gets(str))
	{
		if(str[0]=='_')break;
		int sum=0;
		for(int i=0;i<size;i++)
		{
			if(str[i]=='o')sum+=num[i];
		}
		if(sum==0)printf(" ");
		else printf("%c",sum);
	}	
	return 0;
} 

猜你喜欢

转载自blog.csdn.net/galesaur_wcy/article/details/81092529