我知道那strchr是在<string>.但是uva10082给了CE:
code.cpp: In function ‘int main()’:
code.cpp:6:13: warning: unknown escape sequence: '\A'
char x[] = "`1234567890-=QWERTYUIOP[]\ASDFGHJKL;'ZXCVBNM,./"; ^
code.cpp:11:24: error: ‘strchr’ was not declared in this scope
p = strchr(x, char(c));
Run Code Online (Sandbox Code Playgroud)
这是我的代码:(用c ++ 11编译)
#include<iostream>
#include<string>
using namespace std;
int main()
{
char x[] = "`1234567890-=QWERTYUIOP[]\ASDFGHJKL;'ZXCVBNM,./";
int c;
char* p = NULL;
while ((c = getchar()) != EOF)
{
p =strchr(x,char(c));
if (p)
cout << *(p-1);
else
cout << char(c);
}
}
Run Code Online (Sandbox Code Playgroud)