iT邦幫忙

2024 iThome 鐵人賽

DAY 14
0
佛心分享-刷題不只是刷題

CPE C++ 刷題系列 第 14

CPE C++ 刷題 Day 14

  • 分享至 

  • xImage
  •  

今天來解YKL14(UVA10222):Decode the Mad man

Decode the Mad man

https://ithelp.ithome.com.tw/upload/images/20240928/20155574EdDE0K8Ria.png

這題在講鍵盤上的位移
k->h
[->o
r->w

d->a
y->r
t->e

I->y
[->o
o->u
全部都是往左位移兩格
且要為小寫

#include <iostream>
#include <string>
using namespace std;
int main(){

    string keyboard = "`1234567890-=qwertyuiop[]\asdfghjkl;'zxcvbnm,./";
    string str;
    while(getline(cin,str)){
        for(int i=0;i<=str.size();i++){
            if(str[i] >= 'A' && str[i] <= 'Z')str[i] = str[i] + ('a' - 'A');
            if(str[i]==' '){
                cout << " ";
                continue;
            }
            for(int j=0;j<keyboard.size();j++){
                if(str[i]==keyboard[j]){
                    cout << keyboard[j-2];
                }
            }
        }
        cout << endl;
    }
    return 0;
}

上一篇
CPE C++ 刷題 Day 13
下一篇
CPE C++ 刷題 Day 15
系列文
CPE C++ 刷題20
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言