A - Word Correction

Victor设计了一种独特的文字校正算法,该算法认为含有连续元音的单词有些奇怪并需要修正。修正的方法是删除单词中出现连续元音时的第一个元音字母。本文介绍该算法的工作原理,并给出实现代码。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Victor tries to write his own text editor, with word correction included. However, the rules of word correction are really strange.

Victor thinks that if a word contains two consecutive vowels, then it's kinda weird and it needs to be replaced. So the word corrector works in such a way: as long as there are two consecutive vowels in the word, it deletes the first vowel in a word such that there is another vowel right before it. If there are no two consecutive vowels in the word, it is considered to be correct.

You are given a word s. Can you predict what will it become after correction?

In this problem letters aeiou and y are considered to be vowels.

Input

The first line contains one integer n (1 ≤ n ≤ 100) — the number of letters in word s before the correction.

The second line contains a string s consisting of exactly n lowercase Latin letters — the word before the correction.

Output

Output the word s after the correction.

Example
Input
5
weird
Output
werd
Input
4
word
Output
word
Input
5
aaeaa
Output
a
Note

Explanations of the examples:

  1. There is only one replace: weird  werd;
  2. No replace needed since there are no two consecutive vowels;
  3. aaeaa  aeaa  aa aa  a.
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cctype>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <sstream>
#include<iomanip>
using namespace std;
typedef long long ll;
#define inf int(0x3f3f3f3f)
#define mod int(1e9+7)
#define pi acos(-1)

int main()
{
	int n;
	char s[150];
	   scanf("%d",&n);
	   memset(s,-1,sizeof(s));
	   scanf("%s",s);
		for(int i=0;i<n;i++)
		{
			if(s[i]=='a'||s[i]=='e'||s[i]=='i'||s[i]=='o'||s[i]=='u'||s[i]=='y')
			{
			 for(int j=i+1;j<n;j++)
			 {
			 	if(s[j]==-1) continue;
			 	else if(s[j]=='a'||s[j]=='e'||s[j]=='i'||s[j]=='o'||s[j]=='u'||s[j]=='y')
				{
					s[j]=-1;
					continue;
				}
				else
					break;
			 }
			}
		}
		for(int i=0;i<n;i++)
		{
			if(s[i]!=-1) printf("%c",s[i]);
		}
		printf("\n");
	return 0;
}

c++的写法走一波!

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cctype>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <sstream>
#include<iomanip>
using namespace std;
typedef long long ll;
#define inf int(0x3f3f3f3f)
#define mod int(1e9+7)
#define pi acos(-1)
#define N 1000000005

map<char,int>mp;

void init()
{
	mp['a']=1; mp['e']=1;
	mp['i']=1; mp['o']=1;
	mp['u']=1; mp['y']=1;
}

int main()
{
	int n;
	scanf("%d",&n);
	init();
	string str;
	cin>>str;
	for(int i=0;i<n-1;i++)
	{
		if(mp[str[i]]&&mp[str[i+1]])
		{
			for(int j=i+1;j<n-1;j++)
			{
				str[j]=str[j+1];
			}
			str.erase(str.end()-1);
			n--;
			i--;
		}
	}
	cout<<str<<endl;
	return 0;
}

The DSPR memory of the TC1.6.2P is protected from memory integrity errors on a per half-word basis. ECC protection of the DSPR is enabled via the SSH ECCS register. For data load requests from the TriCore CPU to DSPR, the ECC bits are read along with the data bits and an uncorrectable error signal is generated for each half-word. If an error is detected associated with any of the data half-words passed to the CPU an error is flagged to the CPU. If such an error condition is detected an asynchronous DIE trap is raised. The trap handler is then responsible for correcting the memory entry, or for taking alternative action (such as system soft reset) if correction of the data is not possible. For DSPR read operations from the Bus interface, either from the PMI module or another Bus master agent, an access that results in the detection of an uncorrectable error in the requested data half-words causes an error to be returned for the bus transaction. Since the TriCore CPU may not be involved in the transaction, a separate error is also flagged to the SMU module to optionally generate an NMI trap back to the CPU. For write operations to DSPR of half-word size or greater, the ECC bits are pre-calculated and written to the memory in parallel with the data bits. For byte write operations the memory transaction is transformed into a half-word read-modify-write sequence inside the DMI module. As such, byte write operations may result in the detection of uncorrectable memory integrity errors, which are handled as per standard read operations. 翻译成中文,且帮我理解一下
最新发布
03-08
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值