简单题
View Code
#include
<
iostream
>
#include < cstdio >
#include < cstdlib >
#include < cstring >
using namespace std;
char key[ 4 ][ 20 ];
int main()
{
// freopen("t.txt", "r", stdin);
strcpy(key[ 0 ], " 1234567890-= " );
strcpy(key[ 1 ], " QWERTYUIOP[]\\ " );
strcpy(key[ 2 ], " ASDFGHJKL;' " );
strcpy(key[ 3 ], " ZXCVBNM,./ " );
char st[ 1000 ];
while (gets(st) && strcmp(st, "" ) != 0 )
{
int len = strlen(st);
for ( int i = 0 ; i < len; i ++ )
{
if (st[i] == ' ' )
{
putchar( ' ' );
continue ;
}
bool found = false ;
for ( int j = 0 ; j < 4 ; j ++ )
{
int len1 = strlen(key[j]);
for ( int k = 0 ; k < len1; k ++ )
if (key[j][k] == st[i])
{
putchar(key[j][k - 1 ]);
found = true ;
break ;
}
if (found)
break ;
}
}
putchar( ' \n ' );
}
return 0 ;
}
#include < cstdio >
#include < cstdlib >
#include < cstring >
using namespace std;
char key[ 4 ][ 20 ];
int main()
{
// freopen("t.txt", "r", stdin);
strcpy(key[ 0 ], " 1234567890-= " );
strcpy(key[ 1 ], " QWERTYUIOP[]\\ " );
strcpy(key[ 2 ], " ASDFGHJKL;' " );
strcpy(key[ 3 ], " ZXCVBNM,./ " );
char st[ 1000 ];
while (gets(st) && strcmp(st, "" ) != 0 )
{
int len = strlen(st);
for ( int i = 0 ; i < len; i ++ )
{
if (st[i] == ' ' )
{
putchar( ' ' );
continue ;
}
bool found = false ;
for ( int j = 0 ; j < 4 ; j ++ )
{
int len1 = strlen(key[j]);
for ( int k = 0 ; k < len1; k ++ )
if (key[j][k] == st[i])
{
putchar(key[j][k - 1 ]);
found = true ;
break ;
}
if (found)
break ;
}
}
putchar( ' \n ' );
}
return 0 ;
}