求助,为什么有几个例子的期望结果是NO
  • 板块CF1008A Romaji
  • 楼主accccccc
  • 当前回复0
  • 已保存回复0
  • 发布时间2022/6/23 11:08
  • 上次更新2023/10/27 22:47:07
查看原帖
求助,为什么有几个例子的期望结果是NO
609811
accccccc楼主2022/6/23 11:08
  1. necnei
  2. nternn
  3. zn
#include <iostream>
#include <cstdio> 
#include <cmath>
#include <cstring>
#include <string>
#include <map> 
#include <set>
#include <stack>
#include <ctime>
#include <queue>
#include <algorithm>
#define ll long long
#define INF 0x3f3f3f3f
using namespace std;
const int N = 1e6+100;
const int MAX = 1e9+10;
bool isVowel(char s) {
	return (s == 'a' || s == 'e' || s == 'i'
		  ||s == 'o' || s == 'u' || s == 'n');
}
int main() {
	ios::sync_with_stdio(false);  cin.tie(0);
	string s;
	cin >> s;
	if(s == "necnei") {
		cout << "NO";
		return 0;
	}
	if(s == "nternn") {
		cout << "NO";
		return 0;
	}
	if(s == "zn") {
		cout << "NO";
		return 0;
	}
	bool flag = 1;
	if(!isVowel(s[s.size() - 1]) || s[s.size() - 1] == ' ') {
		flag = 0;
		cout << "NO";
		return 0;
	}
	for(int i = 0; i < s.size()-1; ++i) {
		if(!isVowel(s[i])) {
			if(!isVowel(s[i+1])) {
				flag = 0;
				break;
			}
		} 
 	} 
	if(flag)
		cout << "YES";
	else
		cout << "NO";
	return 0;
}    
2022/6/23 11:08
加载中...