您的位置:首页 > 其它

zoj 1884 || poj 2538 WERTYU(这水让我很YM!)

2010-11-12 21:01 253 查看
输出键盘字符前的那个字符。



开始想,难不能我要用N个case of? = =



后来想通了,把键盘上字符都按顺序存到字符串数组里。。。



少存了 - = WA了数次 !



我了个去!!



学习了一点,scanf可以吃控制字符(空格回车tab等等)。。。 cin不吃。。。



还有str数组里的/,得写俩。。。要不有警告。。。



#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <string.h>
using namespace std;
int main(void)
{
	char ch;
	char str[] = {"`1234567890-=QWERTYUIOP[]//ASDFGHJKL;'ZXCVBNM,./"};
	char text[10000];
	int len = strlen(str);
	while( gets(text) )
	{
		for(int k=0; k<strlen(text); k++)
		{
			if( text[k] == ' ' )
				cout << text[k];
			for(int i=0; i<len; i++)
			{
				if( text[k] == str[i] )
					cout << str[i-1] ;
			}
		}
		cout << endl;
	}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: