0pts 求调
查看原帖
0pts 求调
782768
Mierstan085楼主2023/11/24 16:50
#include <bits/stdc++.h>
using namespace std;

int xp[130], yp[130];
void init(){
    for (int i = 'A'; i <= 'Z'; i ++){
        xp[i] = i / 6 + 1;
        yp[i] = i % 6 + 1;
    }
    xp[' '] = 5, yp[' '] = 3;
    xp['-'] = 5, yp['-'] = 4;
    xp['.'] = 5, yp['.'] = 5;
}

int main(){
    init();
    string s;
    getline(cin, s);
    char bef = 'A';
    int ans = 0;
    for (char i : s){
        ans += abs(xp[i] - xp[bef]) + abs(yp[i] - yp[bef]);
    }
    ans += abs(5 - xp[bef]) + abs(6 - yp[bef]);
    cout << ans;
}
2023/11/24 16:50
加载中...