求助!!!哪里有问题啊?答案都是对的
  • 板块P1765 手机
  • 楼主bxdw
  • 当前回复0
  • 已保存回复0
  • 发布时间2025/1/16 21:32
  • 上次更新2025/1/16 21:39:47
查看原帖
求助!!!哪里有问题啊?答案都是对的
1487481
bxdw楼主2025/1/16 21:32
#include<iostream>
#include<string>
using namespace std;

int main()
{
	char ch1[9] = { 'a','d','g','j','m','p','t','w',' ' }, ch2[] = { 'b','e','h','k','n','q','u','x' }, ch3[] = { 'c','f','i','l','o','r','v','y' }, ch4[] = { 's','z' };
	string str;
	int ans = 0;
	getline(cin,str);
	for (int i = 0; i < str.length(); i++)
	{
		for (int j = 0; j < 9; j++)
		{
			if (str[i] == ch1[j])ans++;
			if (str[i] == ch2[j])ans =ans+ 2;
			if (str[i] == ch3[j])ans =ans+3;
			if (str[i] == ch4[j])ans =ans+ 4;
		}
	}
	cout << ans << endl;
	return 0;
}
2025/1/16 21:32
加载中...