洛谷 P1227 [JLOI2008] 提示问题 题解-编程题目及题解论坛-编程-擎雷博客

洛谷 P1227 [JLOI2008] 提示问题 题解

原题链接(洛谷):https://www.luogu.com.cn/problem/P3880

题解(C++):

#include <bits/stdc++.h>
#define int long long
using namespace std;

const int N = 55;
string s, s3;
bool o = false;
int n = 0, a[N];

signed main() {
	getline(cin, s);//整行读入
	for (int i = 0; i < s.size(); i++) {//输出第一个提示
		if (isalpha(s[i]))a[i] = ++n, cout << ".";
		else cout << s[i];
	}
	cout << endl;

	for (int i = 0; i < s.size(); i++){
		if (isalpha(s[i]) && a[i] > (n + 1) / 3) {
			cout << ".";
			if (s[i] == 'A' || s[i] == 'E' || s[i] == 'I' || s[i] == 'O' || s[i] == 'U' ||
			        s[i] == 'a' || s[i] == 'e' || s[i] == 'i' || s[i] == 'o' || s[i] == 'u')
				o = true, s3 += s[i];
			else s3 += ".";
		} else cout << s[i], s3 += s[i];
	}
		cout << endl;
		if (o) return cout<< s3 << endl, 0;
		for (int i = 0; i < s.size(); i++) {
			if (isalpha(s[i]) && a[i] > (2 * n + 1) / 3)
				cout << ".";
			else cout << s[i];
		}
}
请登录后发表评论

    没有回复内容