PAT甲题题解-1050. String Subtraction (20)-水题
#include <iostream> #include <cstdio> #include <string.h> #include <algorithm>using namespace std; /* 水题,注意字符范围是整个ASCII编码即可。 */ const int maxn=130; int vis[maxn]; char s1[10000+5]; char s2[10000+5];int main() {gets(s1);//getchar(); gets(s2);int len1=strlen(s1);int len2=strlen(s2);for(int i=0;i<len2;i++){ //printf("s2 %c %d\n",s2[i],s2[i]-'0'+48);vis[s2[i]-'0'+48]=1;}char res[10000+5];int cnt=0;for(int i=0;i<len1;i++){if(!vis[s1[i]-'0'+48]){ //printf("s1 %c %d\n",s1[i],s1[i]-'0'+48);res[cnt]=s1[i];cnt++;}}res[cnt]='\0';printf("%s\n",res);return 0; }
View Code
转载于:https://www.cnblogs.com/chenxiwenruo/p/6601369.html
PAT甲题题解-1050. String Subtraction (20)-水题相关推荐
- 【PAT甲级 删除字符串中的指定字符】1050 String Subtraction (20 分) C++
题目 删除字符串中的另一个字符串包含的所有字符. 可以通过判断两个字符串是否为空,来稍微优化一下运行速度 题解C++ #include<iostream> #include<stri ...
- PAT甲级 -- 1050 String Subtraction (20 分)
Given two strings S1 and S2, S=S1−S2 is defined to be the remaining string after taking ...
- PAT:1050. String Subtraction (20) AC
#include<stdio.h> #include<string.h> #include<algorithm> using namespace std; bool ...
- C++ PAT甲级 1050 String Subtraction (20分)
Given two strings S1 and S2, S=S1−S2is defined to be the remaining string aftertaking all the cha ...
- 【PAT (Advanced Level) Practice】1050 String Subtraction (20 分)
C/C++中整型数组的下标类型不一定为整型,C C++语言下数组性质与散列有些类似,即散列中的键值对:下标即为关键码,关键码通过散列函数映射得到元素即为值 下标可以为整型,也可以为字符型,简单案例如下 ...
- 1050 String Subtraction (20 分)_10行代码AC
立志用最少的代码做最高效的表达 PAT甲级最优题解-->传送门 Given two strings S1 and S2, S=S1−S2 is defined to be ...
- PAT甲级1050 String Subtraction
题目 1050 String Subtraction (20 分) Given two strings S1 and S2 , S=S1−S2 is defined to be the remai ...
- PAT甲级1050 String Subtraction:[C++题解]字符串作差
文章目录 题目分析 朴素算法 hash表优化 题目链接 题目分析 遇到的问题:如何删除下标i的值,我的意思是i后面的需要前移吗?还是有好的解决方法. 笔者想到的是打上标记! string读入一整行的方 ...
- 1050 String Subtraction
1050 String Subtraction (20 分) Given two strings S1 and S2, S=S1−S2 is defined to be the ...
最新文章
- input样式和修改
- 优秀平面设计师必须拥有的设计思维
- 使用内置的Gallery应用程序选择图形
- 手机端网站测试用什么软件,3款优秀的移动webAPP网站在线测试工具推荐
- java hessian rmi_RMI,socket,rpc,hessian,http比较
- java学习(19):巩固练习
- 照葫芦画瓢之老男孩购物车程序
- Flutter实战一Flutter聊天应用(七)
- SpringCloudRibbon
- 运算放大器权威指南(Op Amps for Everyone)
- svn创建分支和合并
- 卢松松:寄生式创业更容易成功
- 你终将成为你潜意识中想要成为的人
- axios库读不到cookie_axios客户端无法存储cookie
- Ajax网络请求超时处理-timeout
- linux下的 fopen等
- VS2008中开发wince windows mobile 手持终端程序(PDA软件)
- java获取中文笔画顺序及笔数
- 【文化课每周学习记录】高三上暑假
- rk3288 rlt8723bs蓝牙没有搜索到蓝牙设备并且配对失败