zoukankan      html  css  js  c++  java
  • 1050. String Subtraction

    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<stdio.h>
     2 #include<math.h>
     3 #include<stdlib.h>
     4 #include<string.h>
     5 #include<algorithm>
     6 using namespace std;
     7 
     8 int main()
     9 {
    10     char c, s1[10010], s2[10010];
    11     int i, len1, len2, hashtable[150] = {};
    12     gets(s1);
    13     gets(s2);
    14     len1 = strlen(s1);
    15     len2 = strlen(s2);
    16     for(i = 0; i < len2; i++)
    17     {
    18         c = s2[i];
    19         hashtable[c] = 1;
    20     }
    21     for(i = 0; i < len1; i++)
    22     {
    23         c = s1[i];
    24         if(hashtable[c] == 1)
    25             continue;
    26         printf("%c", c);
    27     }
    28     printf("
    ");
    29     return 0;
    30 }
  • 相关阅读:
    19牛客暑期多校 round2 H 01矩阵内第二大矩形
    NOIP2017滚粗记
    Left 4 Dead 2(求生之路2) 游戏打不开 游戏闪退 的一种可能性以及解决方法
    Luogu P1156 垃圾陷阱
    Luogu P1376 机器工厂
    Luogu P1842 奶牛玩杂技
    Luogu P1880 石子合并
    Luogu P1441 砝码称重(fj省选)
    Luogu P1077 摆花
    Luogu P1282 多米诺骨牌
  • 原文地址:https://www.cnblogs.com/yomman/p/4284486.html
Copyright © 2011-2022 走看看