求助求助啊
  • 板块学术版
  • 楼主happybob
  • 当前回复13
  • 已保存回复13
  • 发布时间2020/11/30 19:33
  • 上次更新2023/11/5 07:01:19
查看原帖
求助求助啊
332914
happybob楼主2020/11/30 19:33

https://www.luogu.com.cn/problem/UVA492

这个题目,这个代码不能过为什么?扔了样例和自测,都没错啊

#include <iostream>
#include <cstdio>
#include <string>
using namespace std;

bool pd(char c)
{
	return (c == 'a' || c == 'A' || c == 'e' || c == 'E' || c == 'i' || c == 'I' || c == 'o' || c == 'O' || c == 'u' || c == 'U');
}
int main()
{
	string s;
	while(cin >> s)
	{
		bool f = false;
		int len = s.length() - 1;
		if(s[len] == '.') f = true;
		if(pd(s[0]))
		{
			if(f)
			{
				cout << s.substr(0, len) << "ay.";
			}
			else
			{
				cout << s << "ay";
			}
		}
		else
		{
			for(int i = 1; i <= (f ? len - 1 : len); i++)
			{
				cout << s[i];
			}
			cout << s.front() << "ay";
			if(f)
			{
				cout << ".";
			}
		}
		char b = getchar();
		cout << b;
	}
	return 0;
}
2020/11/30 19:33
加载中...