pat1050

1050. String Subtraction (20)

时间限制
100 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.
 
   

题目含义是要找出一个不包含一些部分字符的字符串,问题关键在于怎么判断字符串2中的这个字符是否在字符串1中:

可以设计一个不存在列表,里面包含了所有的字符,值是true&false,扫描一遍字符串2,确定哪些要改成true的放在不存在列表中,等到扫描字符串1的时候就看这个字符是否为true,如果不存在,就不输出

#include 
#include
using namespace std;

int main(int argc, const char * argv[]) {
    char s1[10002];
    char s2[10002];
    bool bucunzai[300]={false};
    cin.getline(s1,10002);
    cin.getline(s2,10002);
    int l2=strlen(s2);
    for(int i=0;i





你可能感兴趣的:(pat)