1050. String Subtraction

Source: Internet
Author: User

Given-Strings S1 and S2, s = S1-s 2 is defined to being theremaining string after taking all the Charac Ters in S2 from S1. Your task is simply to calculate S1-s2 for any given strings. However, it might is not is, simple-to-do it fast.

Input Specification:

Each input file contains the one test case. Each case consists of lines which gives S1and S 2, respectively. The string lengths of both strings is no more than4. It is guaranteed and a new line character signals the end of the characters is visible ASCII codes and white space of a string.

Output Specification:

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


Strlen () is a loop in itself, so don't use it in the loop, it's timed out

#include <stdio.h> #include <stdlib.h> #include <string.h> #define N 10001int Main () {    char str1[n] , Str2[n];    BOOL flag[92];    memset (flag,0,sizeof (flag));    Gets (STR1);    Gets (STR2);    int i,length;    Length=strlen (STR2);    for (i=0;i<length;i++)    {         flag[str2[i]-']=true;         }    Length=strlen (STR1);    for (i=0;i<length;i++)    {         if (flag[str1[i]-']!=true) printf ("%c", Str1[i]);         }    printf ("\ n");    System ("pause");    return 0;    }


1050. String Subtraction

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.