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

    Given two strings S~1~ and S~2~, S = S~1~ - S~2~ is defined to be the remaining string after taking all the characters in S~2~ from S~1~. Your task is simply to calculate S~1~ - S~2~ 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 S~1~ and S~2~, respectively. The string lengths of both strings are no more than 10^4^. 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 S~1~ - S~2~ in one line.

    Sample Input:

    They are students.
    aeiou
    

    Sample Output:

    Thy r stdnts.

    注意点:连个字符串都可能包含空格, 要用getline输入
    #include<iostream>
    #include<vector>
    using namespace std;
    int main(){
      string s, s1;
      getline(cin, s);
      getline(cin, s1);
      int i;
      vector<int> v(128,-1);
      for(i=0; i<s1.size(); i++) v[s1[i]] = 1;
      for( i=0; i<s.size(); i++)
      if(v[s[i]]!=1) cout<<s[i];
      return 0;
    }
    有疑惑或者更好的解决方法的朋友,可以联系我,大家一起探讨。qq:1546431565
  • 相关阅读:
    构建之法阅读笔记05
    构建之法阅读笔记04
    构建之法阅读笔记03
    学习进度条
    软件工程练习——买书
    软件工程练习——找水王2
    Java作业07
    Java课堂作业06
    读《大道至简》第六章有感
    Java课堂作业05
  • 原文地址:https://www.cnblogs.com/mr-stn/p/9178768.html
Copyright © 2011-2022 走看看