Enter a string determines the character set included in the string.

  • Title
    enter a string determines the character set included in the string.

  • Input Description
    each data input a string with a maximum length of 100, and only contains the characters, it can not be the empty string, case sensitive.

  • Description output
    of each data line, according to the character string of the original order, the output set of characters, i.e. letters after repeated and by not output.

  • Examples

    输入
    abcqwerabc
    
    输出
    abcqwer
    
  • Code

    import java.util.Scanner;
    
    class Solution {
        public static void main(String [] args) {
            Scanner in = new Scanner(System.in);
            String s1 = in.nextLine();
            if (s1 == null || s1.length() > 100) {
                return;
            }
            for (int i = 0; i < s1.length(); i++) {
                for (int j = i+1; j < s1.length(); j++) {
                    if (s1.charAt(i) == s1.charAt(j)) {
                        s1 = s1.substring(0,j)+s1.substring(j+1,s1.length());
                    }
                }
            }
            System.out.println(s1);
        }
    }
    
  • operation result

    abcqwerabc
    abcqwer
    
Published 70 original articles · won praise 4 · Views 6355

Guess you like

Origin blog.csdn.net/qq_44837912/article/details/104679327