首页 > 其他 > 详细

【PAT甲级】1050 String Subtraction (20 分)

时间:2019-10-02 11:57:59      阅读:99      评论:0      收藏:0      [点我收藏+]

题意:

输入两个串,长度小于10000,输出第一个串去掉第二个串含有的字符的余串。

trick:

ascii码为0的是NULL,减去‘0‘,‘a‘,‘A‘,均会导致可能减成负数。

代码:

#define HAVE_STRUCT_TIMESPEC
#include<bits/stdc++.h>
using namespace std;
char s1[10007],s2[10007];
int vis[507];
int main(){
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cin.getline(s1,10005);
cin.getline(s2,10005);
int n=strlen(s1);
int m=strlen(s2);
for(int i=0;i<m;++i)
vis[s2[i]-NULL]=1;
for(int i=0;i<n;++i)
if(!vis[s1[i]-NULL])
cout<<s1[i];
return 0;
}

【PAT甲级】1050 String Subtraction (20 分)

原文:https://www.cnblogs.com/ldudxy/p/11616884.html

(1)
(1)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!