题目描述: 输入字符串s和字符c,要求去掉s中所有的c字符,并输出结果。 输入: 测试数据有多组,每组输入字符串s和字符c。 输出: 对于每组输入,输出去除c字符后的结果。 样例输入: heallo a 样例输出: hello
import java.util.*; public class Main { public static void main(String args[]) { Scanner cin = new Scanner(System.in); while(cin.hasNext()){ String a = cin.nextLine(); String b = cin.nextLine(); String[] st = a.split(b); String result = ""; for(int i = 0 ; i < st.length ; i++) result += st[i]; System.out.println(result); } } }题目描述: 给定两个整数A和B,其表示形式是:从个位开始,每三位数用逗号”,”隔开。 现在请计算A+B的结果,并以正常形式输出。 输入: 输入包含多组数据数据,每组数据占一行,由两个整数A和B组成(-10^9 < A,B < 10^9)。 输出: 请计算A+B的结果,并以正常形式输出,每组数据占一行。 样例输入: -234,567,890 123,456,789 1,234 2,345,678 样例输出: -111111101 2346912
import java.util.*; public class Main { public static void main(String args[]) { Scanner cin = new Scanner(System.in); while(cin.hasNext()){ String a = cin.nextLine(); //根据空格的位置,取得两个数 String[] st = a.split(" "); //去掉逗号 String[] b = st[0].split(","); String[] c= st[1].split(","); String result1 = ""; String result2 = ""; for(int i = 0 ; i < b.length ; i++) result1 += b[i]; for(int j = 0 ; j < c.length ; j++) result2 += c[j]; int r1 = Integer.parseInt(result1); int r2 = Integer.parseInt(result2); System.out.println(r1 + r2); } } }这两题实际都是在考察,去掉字符串的特定字符,所以放在了一起做。