zoukankan      html  css  js  c++  java
  • pat1050. String Subtraction (20)

    1050. String Subtraction (20)

    时间限制
    10 ms
    内存限制
    65536 kB
    代码长度限制
    16000 B
    判题程序
    Standard
    作者
    CHEN, Yue

    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:
    They are students.
    aeiou
    
    Sample Output:
    Thy r stdnts.
    

    提交代码

     1 #include<cstdio>
     2 #include<algorithm>
     3 #include<iostream>
     4 #include<cstring>
     5 #include<queue>
     6 #include<vector>
     7 #include<cmath>
     8 #include<string>
     9 #include<map>
    10 #include<set>
    11 using namespace std;
    12 bool ha[128];//ACSII码范围  0-127
    13 int main(){
    14     //freopen("D:\INPUT.txt","r",stdin);
    15     string s1,s2,s3;
    16     getline(cin,s1);
    17     getline(cin,s2);
    18     int i;
    19     for(i=0;i<s2.length();i++){
    20         ha[s2[i]]=true;
    21     }
    22     s3="";
    23     for(i=0;i<s1.length();i++){
    24         if(!ha[s1[i]]){
    25             s3=s3+s1[i];
    26         }
    27     }
    28     cout<<s3<<endl;
    29     return 0;
    30 }
  • 相关阅读:
    DDD之3实体和值对象
    DDD之2领域概念
    DDD之1微服务设计为什么选择DDD
    SOFA入门
    COLA的扩展性使用和源码研究
    kafka可插拔增强如何实现?
    请设计一个核心功能稳定适合二开扩展的软件系统
    如何保证kafka消息不丢失
    kafka高吞吐量之消息压缩
    kafka消息分区机制原理
  • 原文地址:https://www.cnblogs.com/Deribs4/p/4771704.html
Copyright © 2011-2022 走看看