编一个程序,判断输入的字符申是否属于集合
属于,输出'Y’,不属于,输出’N’
例如:abbbdd,aaccd,abbcd,aaadddd是集合中的元素
void judge(char str[],int length){
if(str[0]!='a'||str[length-1]!='d'){
printf("N");
return;
}
int k=0;
while(str[k]=='a') k++;
while(str[k]=='b') k++;
while(str[k]=='c') k++;
while(str[k]=='d') k++;
if(k==length)
printf("Y");
else
printf("N");
}
int main(){
char str[100];
int length=0;
scanf("%s",str);
while(str[length]!='\0')length++;
judge(str,length);
}
标签:判断,15,++,while,int,length,str,printf,集合
From: https://blog.csdn.net/j000405/article/details/141389041