Experimental 7-3-10 delete repeating characters (20 points)

Experimental 7-3-10 delete repeating characters (20 points)

This problem requires programming, given the repeated character string is removed, according to the ASCII character sequence in ascending order are output.

Input formats:

Is input to a non-empty string enter the end (less than 80 characters).

Output formats:

To re-output the result sorted string.

Sample input:

ad2f3adjfeainzzzv

Sample output:

23adefijnvz

Code:

#include <stdio.h>

#define N 81
	
int main()
{
    int i=0,item,ascii[128]={0};
	char str[N];
	gets(str);
	//标记ascii表
	for(i=0;str[i]!='\0';i++)
	{
		item=(int)(str[i]);
		if(ascii[item]==0)
			ascii[item]=1;
		
	}
	//遍历ascii表输出存在的数
	for(i=0;i<128;i++)
	{
		if(ascii[i])
			printf("%c",i);	
	}
		
	
    return 0;
}
Published 140 original articles · won praise 10 · views 6432

Guess you like

Origin blog.csdn.net/qq_35891520/article/details/105310311