代码如下,不知道为啥错
查看原帖
代码如下,不知道为啥错
1249810
NachoDoritosLOL楼主2024/11/7 22:09
#include<bits/stdc++.h>
using namespace std;
int main(){
	char c[27],a='a';
	for(int i=0;i<26;i++){
		c[i]=a;
		a++;
	}
	c[26]=' ';
	int times[27]={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,1},sum,charcnt;
	string str;
	cin>>str;
	charcnt=str.size();
	for(int i=0;i<charcnt;i++){
		for(int j=0;j<27;j++){
			if(str[i]==c[j]){
				sum+=times[j];
			}
		}
	}
	cout<<sum;
	return 0;
}

2024/11/7 22:09
加载中...