求hack
  • 板块UVA492 Pig-Latin
  • 楼主happybob
  • 当前回复0
  • 已保存回复0
  • 发布时间2020/11/28 10:21
  • 上次更新2023/11/5 07:12:23
查看原帖
求hack
332914
happybob楼主2020/11/28 10:21
#include <iostream>
#include <cstdio>
#include <string>
using namespace std;

bool pd(const 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 <= len; i++)
			{
				cout << s[i];
			}
			cout << s.front() << "ay";
			if(f)
			{
				cout << ".";
			}
		} 
		char b = getchar();
		cout << b;
	}
	return 0;
}
2020/11/28 10:21
加载中...