-
Description:
-
The input string S and character C must be removed from all the C characters in S and output results.
-
Input:
-
There are multiple groups of test data, with each group of input strings S and character C.
-
Output:
-
For each group of inputs, the output results after the C characters are removed.
-
Sample input:
-
healloa
-
Sample output:
-
hello
-
Source:
-
A trial of computer research vitality of Harbin Institute of Technology in 2009
1 import java.math.BigInteger; 2 import java.util.Arrays; 3 import java.util.Scanner; 4 5 public class Main{ 6 public static void main(String[]args){ 7 Scanner in=new Scanner(System.in); 8 while(in.hasNext()){ 9 String s=in.nextLine();10 String t=in.nextLine();11 char c=t.charAt(0);12 char[]s2c=s.toCharArray();13 int len=s2c.length;14 s="";15 for(int i=0;i<len;i++){16 if(s2c[i]==c) continue;17 s+=s2c[i];18 }19 System.out.println(s);20 }21 }22 }23 24 /**************************************************************25 Problem: 104926 User: 0000H27 Language: Java28 Result: Accepted29 Time:80 ms30 Memory:15416 kb31 ****************************************************************/
Question 1049: Remove a specific character from a string