A-B

11 篇文章 0 订阅

7-3 A-B (20 分)
本题要求你计算A−B。不过麻烦的是,A和B都是字符串 —— 即从字符串A中把字符串B所包含的字符全删掉,剩下的字符组成的就是字符串A−B。

输入格式:
输入在2行中先后给出字符串A和B。两字符串的长度都不超过10
​4
​​ ,并且保证每个字符串都是由可见的ASCII码和空白字符组成,最后以换行符结束。

输出格式:
在一行中打印出A−B的结果字符串。

输入样例:
I love GPLT! It’s a fun game!
aeiou
输出样例:
I lv GPLT! It’s fn gm!
1.set

if(w.find(a[i])==w.end() ) p.push(a[i]);
while(!p.empty()){
printf("%c",p.front());
p.pop();
}

#include<cstdio>
#include<cstring>
#include<set>
#include<queue>
using namespace std;
char a[10000+10];
int main(){
	char c;
	queue<char> p;
	set<char> w;
	int t=0,i;
	while((c=getchar())!=EOF&&c!='\n'){
		a[t]=c;
		t++;
	}
	while((c=getchar())!=EOF&&c!='\n'){
		w.insert(c); 
		
	}
	for(i=0;i<t;i++){
		if(w.find(a[i])==w.end()  )  p.push(a[i]);
	}
	while(!p.empty()){
		printf("%c",p.front());
		p.pop();
	}
	
	return 0;
}

for(i=0;i<t1;i++){
if(book[a[i]]==1) continue;
printf("%c",a[i]);
}

#include<cstdio>
#include<cstring>
using namespace std;
char a[10000+10];
int book[300];
int main(){
	char c;

	int t1=0,i;
	while((c=getchar())!=EOF&&c!='\n'){
		a[t1]=c;
		t1++;
	}
	while((c=getchar())!=EOF&&c!='\n'){
		book[c]=1;
			
	}

	for(i=0;i<t1;i++){
		if(book[a[i]]==1) continue;
		printf("%c",a[i]);
	}
	return 0;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值