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 }
  • 相关阅读:
    Java计算某个日期是一年中的第几天
    k8s-CentOs7.x 搭建集群(1)(kubelet 1.19.2)
    k8s-PV、PVC(7)
    k8s-Volumes(6)
    k8s-Scale、Rolling Update(5)
    k8s-Service介绍(4)
    k8s-部署AspNetCore应用(3)
    k8s-搭建Dashboard(2)
    AspNetcore搭配Serilog利用docker发布CentOs7
    CentOs7 搭建http服务器访问文件目录
  • 原文地址:https://www.cnblogs.com/Deribs4/p/4771704.html
Copyright © 2011-2022 走看看