不知为何出错?(满江红)
  • 板块P1765 手机
  • 楼主zzh0118
  • 当前回复0
  • 已保存回复0
  • 发布时间2024/1/9 17:49
  • 上次更新2024/1/9 17:49:48
查看原帖
不知为何出错?(满江红)
1016479
zzh0118楼主2024/1/9 17:49

代码如下:

#include <bits/stdc++.h>
using namespace std;
int s__(char c){
    if(!(c >= 'a' && c <= 'z') || !(c == ' ')){
        return 0;
    }
    if(c=='a'||c=='d'||c=='g'||c=='j' ||c=='m'||c=='p'||c=='t'||c=='w'||c==' '){
        return 1;
    }
    if(c=='b'||c=='e'||c =='h'||c=='k'||c=='n'||c=='q'||c=='u'||c=='x'){
        return 2;
    }
    if(c=='c'||c=='f'||c=='i'||c =='l'||c =='o'||c=='r'||c=='v'||c=='y'){
        return 3;
    }
    if(c=='s'||c=='z'){
        return 4;
    }
}

int main(){
    string s;
    int cnt = 0;
    getline(cin, s);
    int n = s.size();
    for(int i = 0; i <= n - 1; i++)
    {
        cnt += s__(s[i]) }cout << cnt;return 0;
}

求大佬帮改

2024/1/9 17:49
加载中...