1050. String subtraction (20)-pat

Source: Internet
Author: User
1050. String subtraction (20) Time limit 10 ms memory limit 32000 kb code length limit 16000 B discriminant program standard

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 itFast.

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.
Recommendation index :※
Source: http://pat.zju.edu.cn/contests/pat-a-practise/1050
Simply think about it.
#include<iostream>#include<string.h>#include<stdio.h>using namespace std;#define  N 128int main(){int i=0,sum;bool is_exist[N];char ch;char str[10000];memset(is_exist,0,sizeof(is_exist));while(scanf("%c",&ch)&&ch!='\n'){is_exist[ch]=true;str[i++]=ch;}sum=i;while(scanf("%c",&ch)&&ch!='\n'){is_exist[ch]=false;}i=0;while(i<sum){if(is_exist[str[i]]!=false)printf("%c",str[i]);i++;}return 0;}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.