#include <iostream> using namespace std; int chazhao(int sum,string sum1){ if(sum1=="a" || sum1=="d" || sum1=="g" || sum1=="j" || sum1=="m" || sum1=="p" || sum1=="t" ||sum1=="w"){ return 1; }else if(sum1=="b" || sum1=="e" || sum1=="h" || sum1=="k" || sum1=="n" || sum1=="q" || sum1=="u" ||sum1=="x"){ return 2; }else if(sum1=="c" || sum1=="f" || sum1=="i" || sum1=="l" || sum1=="o" || sum1=="r" || sum1=="v" ||sum1=="y"){ return 3; }else if(sum1=="s" || sum1=="z"){ return 4; } } int main() { int n,sum = 0; string sum1; cin>>n; string a; for(int i = 0;i<n;i++){ cin>>a; if(a.size()<2){ sum+=chazhao(sum,a); }else{ for(int j = 0;j<a.size();j++){ sum+=chazhao(sum,a.substr(j,1)); } } } cout<<sum+n-1; return 0; }
标签:return,试题,int,sum,sum1,else,C++,string From: https://www.cnblogs.com/wangyihang-xh/p/17110059.html