题意:无聊的字符串模拟。每个字符只输出第一次出现,并且过滤掉元音。
思路:模拟。注意标点之前不能有空格(代码中space变量的作用,而不是每个单词后直接输出空格)
#include <stdio.h>
#include <string.h>
#define N 75
char s[N];
int used[30];
int isvowel(char x){
return x=='A'||x=='E'||x=='I'||x=='O'||x=='U';
}
int main(){
int i,flag,space=0;
gets(s);
for(i = 0;s[i]!='\0';i++){
flag = 0;
while(s[i]!=' '&&s[i]!='\0'){
if(s[i]>='A'&&s[i]<='Z'&&(isvowel(s[i]) || used[s[i]-'A'])){
i++;
continue;
}
if(s[i]>='A'&&s[i]<='Z'&&!used[s[i]-'A']){
used[s[i]-'A'] = 1;
if(spac