码农知识堂 - 1000bd
  •   Python
  •   PHP
  •   JS/TS
  •   JAVA
  •   C/C++
  •   C#
  •   GO
  •   Kotlin
  •   Swift
  • PAT 1050 String Subtraction


    1050 String Subtraction

    Given two strings S1​ and S2​, S=S1​−S2​ is defined to be the remaining string after taking all the characters in S2​ from S1​. Your task is simply to calculate S1​−S2​ for any given strings. However, it might not be that simple to do it fast.

    Input Specification:

    Each input file contains one test case. Each case consists of two lines which gives S1​ and S2​, respectively. The string lengths of both strings are no more than 104. It is guaranteed that all the characters are visible ASCII codes and white space, and a new line character signals the end of a string.

    Output Specification:

    For each test case, print S1​−S2​ in one line.

    Sample Input:

    1. They are students.
    2. aeiou

    Sample Output:

    Thy r stdnts.

    总结:这道题还是很简单的,用一个ascii数组标记s2出现过的字符,然后遍历s1字符串,遇到标记过的字符就不打印,反之则打印

    1. #include
    2. using namespace std;
    3. int main(){
    4. string a,b;
    5. int ascii[128]={0};
    6. getline(cin,a);
    7. getline(cin,b);
    8. for(auto c:b) ascii[c]=1;
    9. for(auto c:a){
    10. if(ascii[c]) continue;
    11. printf("%c",c);
    12. }
    13. return 0;
    14. }

     好好学习,天天向上!

    我要考研!

  • 相关阅读:
    Java进阶——IO流
    晶振工作原理详解
    NFS安装配置
    ElasticSearch 实现 全文检索 支持(PDF、TXT、Word、HTML等文件)通过 ingest-attachment 插件实现 文档的检索
    【论文笔记】图神经网络采样相关工作整理9.19
    VBS脚本、BAT批处理脚本大公开,功能强大,简单易用 —— 定时执行专家
    Day10:基础入门-HTTP数据包&Postman构造&请求方法&请求头修改&状态码判断
    4.2EF Core的实体类配置
    用嘉立创查找元件的原理图
    Python Selenium 基本使用(详细步骤)
  • 原文地址:https://blog.csdn.net/weixin_50679551/article/details/127039029
  • 最新文章
  • 【JVM】编译执行与解释执行的区别是什么?JVM 使用哪种方式?
    用 Hashids 优雅解决 C 端自增 ID 暴露问题
    V8引擎 精品漫游指南--Ignition篇(上) 指令 栈帧 槽位 调用约定 内存布局 基础内容
    LLVM Pass快速入门(四):代码插桩
    milkup:桌面端 markdown AI续写和即时渲染
    基于项目工程构建SBOM(软件物料清单)的研究
    鸿蒙应用开发UI基础第二节:鸿蒙应用程序框架核心解析与实操
    .NET 中如何快速实现 List 集合去重?
    扣子Coze实战:从0到1打造抖音+小红书热点监控智能体
    浅谈数据访问层
  • 热门文章
  • 十款代码表白小特效 一个比一个浪漫 赶紧收藏起来吧!!!
    奉劝各位学弟学妹们,该打造你的技术影响力了!
    五年了,我在 CSDN 的两个一百万。
    Java俄罗斯方块,老程序员花了一个周末,连接中学年代!
    面试官都震惊,你这网络基础可以啊!
    你真的会用百度吗?我不信 — 那些不为人知的搜索引擎语法
    心情不好的时候,用 Python 画棵樱花树送给自己吧
    通宵一晚做出来的一款类似CS的第一人称射击游戏Demo!原来做游戏也不是很难,连憨憨学妹都学会了!
    13 万字 C 语言从入门到精通保姆级教程2021 年版
    10行代码集2000张美女图,Python爬虫120例,再上征途
小工具 小游戏
Copyright © 2022 侵权请联系2656653265@qq.com    京ICP备2022015340号-1

京公网安备 11010502049817号