/*
Enter a string of lowercase letters (A~Z) through the keyboard. Write a string filter to filter out characters that are not the first occurrence if multiple identical characters appear in the string.
For example, the string "ABACACDE" filter result is "ABCDE".
Required implementation functions:
void Stringfilter (const char *PINPUTSTR, long Linputlen, Char *poutputstr);
"Input" PINPUTSTR: input string
Linputlen: Input string length
"Output" POUTPUTSTR: output string, space has been opened up, and input string length;
"Note" Only needs to complete the function algorithm, the middle does not need any IO input and output
Example
Input: "DEEFD" Output: "Def"
Input: "AFAFAFAF" Output: "AF"
Input: "PPPPPPPP" Output: "P"
*/
1 PackageHuawei Machine test;2 3 4 ImportJava.util.Scanner;5 6 7 Public classMain2 {8 9 Public Static voidMain (string[] args) {Ten //TODO auto-generated Method Stub OneScanner scn=NewScanner (system.in); AString s=Scn.next (); - Charc[]=S.tochararray (); - Booleanexit[]=New Boolean[26]; the intIndex=0; - - for(inti=0;i<c.length;i++) - { + if(!exit[c[i]-' a ']) - { +exit[c[i]-' A ']=true; Ac[index++]=C[i]; at } - - } -System.out.println (NewString (c). substring (0, index)); - } - in}
Filter strings (Java)