C Programming second Edition 2.4 exercises

Source: Internet
Author: User

#include <stdio.h>
/*
Rewrite Squeeze (s1,s2) to string S1 any characters in the string S2
The matching characters are deleted.
*/
#define MAX 10
Char C[max];

int main () {
Char A[max] = "ABCDEFG";
Char B[max] = "Abcdffe";
void Squeeze (char A[],char b[]);
Squeeze (A, b);
printf ("%s\n", c);
}void squeeze (char a[], char b[]) {

int i,j;
int k=0;
int count;
for (i=0;i<max;i++) {
count=0; is important
for (j=0;j<max;j++) {
if (a[i]! = B[j]) {//If the characters in a[i] are not equal to any of the characters in B[0]-b[9] count value plus 1
count++;
}
else count=0; Count clear 0 if a[i] is equal to an element in the middle of b[0]-b[9]
if (count = = 9) {//only a[i that can add count to 9] is not in the B array to put this character in the C "" Array
Count = 0;
C[k]=a[i];
k++;
}
}
}

C Programming second Edition 2.4 exercises

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.