Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- void func( char c)
- {
- char str[] = "1234567890-=qwertyuiop[]\\asdfghjkl;'zxcvbnm,./"; //把整個鍵盤打出來
- if( c == ' '){ //遇到空白印空白
- cout << " ";
- }
- else if( c >= 'A' && c <= 'Z'){ //遇到大寫轉小寫
- c = c + 32;
- }
- for( int i = 0; i < strlen(str); i++){
- if( c == str[i]){
- cout << str[i-2]; //印出字元c在鍵盤左邊的第二個字
- }
- }
- }
- int main()
- {
- string str;
- while( getline( cin, str)){
- for( int i = 0; i < str.size(); i++){
- func( str[i]); //印出解碼結果
- }
- cout << endl; //記得換行
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement