【转】http://blog.youkuaiyun.com/zxy_snow/article/details/6005878
输出键盘字符前的那个字符。
#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;
}
本文介绍了一个简单的C++程序,该程序能够读取输入文本并输出每个字符前的字符。通过查找预定义的字符串来匹配输入文本中的字符,并打印出匹配字符前的一个字符。
656

被折叠的 条评论
为什么被折叠?



