WA代码求助
  • 板块P1765 手机
  • 楼主ouyangdou
  • 当前回复1
  • 已保存回复3
  • 发布时间2024/9/18 21:36
  • 上次更新2024/9/19 11:56:33
查看原帖
WA代码求助
1388282
ouyangdou楼主2024/9/18 21:36
```cpp
#include<bits/stdc++.h>
using namespace std;
int p[26]={1,2,3,1,2,3,1,2,3,1,2,3,1,2,3,1,2,3,4,1,2,3,1,2,3,4};
int f(char x){
    if('a'<=x&&x<='z')return p[x-'a'];
    if(x==' ')return 1;
    return 0;
}
int main(){
    char a;
    int ans=0;
    while(cin>>a){
        ans+=f(a);
    }
    cout<<ans;
    return 0;
}
2024/9/18 21:36
加载中...