Answered You can hire a professional tutor to get the answer.

QUESTION

This is my work. #includelt;stdio.

Need help with this project attached.

This is my work.

#include<stdio.h>void delete_set(int v, int a[]);void set_difference(int a[], int b[], int c[]);void sym_difference(int a[], int b[], int c[]);

int aSetLength = 0;int bSetLength = 0;int cSetLength = 0;

int main() {int a[50], b[50], c[50];int i;printf("Enter length of Set a: ");scanf("%d", &aSetLength);

printf("Enter a Set elements:n");for (i = 0; i < aSetLength; i++) {scanf("%d", &a[i]);}

printf("Enter length of Set b: ");scanf("%d", &bSetLength);

printf("Enter b Set elements:n");for (i = 0; i < bSetLength; i++) {scanf("%d", &b[i]);}

printf("Set a content: n");for (i = 0; i < aSetLength; i++) {printf("%d ", a[i]);}

printf("nSet b content: n");for (i = 0; i < bSetLength; i++) {printf("%d ", b[i]);}

//call set difference functionset_difference(a, b, c);printf("nSet difference result: n");for (i = 0; i < cSetLength; i++) {printf("%d ", c[i]);}

sym_difference(a, b, c);printf("nSymmetric difference result: n");for (i = 0; i < cSetLength; i++) {printf("%d ", c[i]);}return 0;}

void delete_set(int v, int a[]) {

int pos = -1, i, c;//find positionfor (i = 0; i < aSetLength; i++) {if (a[i] == v) {pos = i;break;}}if (pos == -1) {printf("No element to deleten");} else {for (c = pos - 1; c < aSetLength - 1; c++)a[c] = a[c + 1];

aSetLength--;}}

void set_difference(int a[], int b[], int c[]) {

int i, j;int notExist = 0;cSetLength = 0;

for (i = 0; i < aSetLength; i++) {notExist = 0;for (j = 0; j < bSetLength; j++) {if (a[i] == b[j]) {notExist = 1;break;}}if (notExist == 0) {c[cSetLength++] = a[i];}}

}

void sym_difference(int a[], int b[], int c[]) {

int unionRes[50], uniionLen, symRes[50];int i = 0;int j = 0;int k = 0;int found = 0;

cSetLength = 0;set_difference(a, b, c);

for (i = 0; i < aSetLength; i++) {found = 0;for (k = 0; k < j; k++) {if (unionRes[k] == a[i])found = 1;}if (!found) {unionRes[j] = a[i];j++;}}

for (i = 0; i < bSetLength; i++) {found = 0;for (k = 0; k < j; k++) {if (unionRes[k] == b[i])found = 1;}if (!found) {unionRes[j] = b[i];j++;}}uniionLen = j;j = 0;for (i = 0; i < uniionLen; i++) {found = 0;for (k = 0; k < cSetLength; k++) {if (c[k] == unionRes[i])found = 1;}

if (!found) {symRes[j] = unionRes[i];j++;}}

cSetLength = 0;for (i = 0; i < j; i++) {c[cSetLength++] = symRes[i];}

}

I need help printing the union and intersection.

deleting element from set and printing result and my symmetric difference is wrong

Show more
LEARN MORE EFFECTIVELY AND GET BETTER GRADES!
Ask a Question