⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 2279154_pe.cpp

📁 北大大牛代码 1240道题的原代码 超级权威
💻 CPP
字号:
#include <stdio.h>
#include <string.h>

int f(char ch)
{
	return ch-'A';
}

int g(char ch)
{
	if(ch=='A'||ch=='E'||ch=='I'||ch=='O'||ch=='U')
		return 0;
	return 1;
}

int main()
{
	int i, l = 0;
	char str[100];
	char out[100];
	int mark[30];

	gets(str);
	memset(mark,0,sizeof(mark));
	i = 0;
	while(str[i]==' ')
		i++;
	strcpy(str,&str[i]);
	i = strlen(str)-1;
	while(str[i]==' ')
		i--;
	str[i+1] = '\0';
	for(i = 0; str[i] != '\0'; i++)
	{
		if(!g(str[i]))
			continue;
		if(str[i]==' '||str[i]==','||str[i]=='.'||str[i]=='?'||mark[f(str[i])]==0)
		{
			if(str[i]>='A'&&str[i]<='Z')
				mark[f(str[i])] = 1;
			out[l++] = str[i];
		}
	}
	out[l] = '\0';
	i = 0;
	while(out[i]==' ')
		i++;
	strcpy(out,&out[i]);
	i = strlen(out)-1;
	while(out[i]==' ')
		i--;
	out[i+1] = '\0';
	l = i+1;
	for(i = 0; out[i]!='\0'; i++)
		if(out[i]==' ')
		{
			int j = i;
			while(out[j]==' ')
				j++;
			strcpy(&out[i+1],&out[j]);
			if(out[i+1]<'A'&&out[i+1]>'Z')
				strcpy(&out[i],&out[i+1]);
		}
	puts(out);
	return 1;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -