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 }
  • 相关阅读:
    20170519
    20170515
    20170511
    20170509
    20170505
    使用 FirewallD 构建动态防火墙
    Elasticsearch 5.2.1Cluster 搭建
    elk,centos7,filebeat,elasticsearch-head详细安装步骤
    elk,centos7,filebeat,elasticsearch-head集成搭建
    memcached
  • 原文地址:https://www.cnblogs.com/Deribs4/p/4771704.html
Copyright © 2011-2022 走看看