本题要求你计算A−B。不过麻烦的是,A和B都是字符串 —— 即从字符串A中把字符串B所包含的字符全删掉,剩下的字符组成的就是字符串A−B。
输入格式:
输入在2行中先后给出字符串A和B。两字符串的长度都不超过104,并且保证每个字符串都是由可见的ASCII码和空白字符组成,最后以换行符结束。
输出格式:
在一行中打印出A−B的结果字符串。
输入样例:
I love GPLT! It's a fun game!
aeiou
输出样例:
I lv GPLT! It's fn gm!
#include <stdio.h>
#include<string.h>
int main()
{
char a[100001];
char b[100001];
gets(a);
gets(b);
for(int i = 0;i< strlen(a);i++){
if(strchr(b,a[i])){
continue;
}else{
printf("%c",a[i]);
}
}
}
package com.lb;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader sc = new BufferedReader(new InputStreamReader(System.in));
String s1 = sc.readLine();
String s2 = sc.readLine();
String s3 = s1.replaceAll("["+s2+"]","");
System.out.println(s3);
}
}