问题 D: String Subtraction (20)

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_34432960/article/details/88081740

题目描述

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 - S2for any given strings. However, it might not be that simple to do it fast.

输入

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.

输出

For each test case, print S1 - S2 in one line.

样例输入

They are students.
aeiou

样例输出

Thy r stdnts.
#include<stdio.h>
#include<iostream>
#include<string.h>
using namespace std;
char s1[10010];
char s2[10010];
int main()
{
	//int letter[200]={0};
	bool letter[200]={false};
	while(gets(s1))
	{	char c;
		gets(s2);
		//printf("/////1////\n");
		int len2=strlen(s2);
		for(int i=0;i<len2;i++)
		{
			c=s2[i];
			letter[c]=true;
		}
		int len1=strlen(s1);
		for(int i=0;i<len1;i++)
		{
			//printf("%c",s1[i]);
			c=s1[i];
			if(letter[c]!=true)
			{
			printf("%c",c);
			}
		}
		printf("\n");
	}
	return 0;
}
/*
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#include<string.h>
#include<algorithm>
using namespace std;

int main()
{
    char c, s1[10010], s2[10010];
    int i, len1, len2, hashtable[150] = {};
    gets(s1);
    gets(s2);
    len1 = strlen(s1);
    len2 = strlen(s2);
    for(i = 0; i < len2; i++)
    {
        c = s2[i];
        hashtable[c] = 1;
    }
    for(i = 0; i < len1; i++)
    {
        c = s1[i];
        if(hashtable[c] == 1)
            continue;
        printf("%c", c);
    }
    printf("\n");
    return 0;
}
*/

猜你喜欢

转载自blog.csdn.net/qq_34432960/article/details/88081740