ArfIsAToe

difference symetrique for sinda

Jun 8th, 2021 (edited)
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.51 KB | None | 0 0
  1. #include <stdio.h>
  2. void aff(int t[],int n,char x)
  3. {
  4.     printf("This is your array %c:\n______________________________\n{",x);
  5.     for (int a=0;a<n;a++)
  6.     {
  7.         if(a<n-1)
  8.             printf("%d,\t",t[a]);
  9.         else
  10.             printf("%d",t[a]);
  11.     }
  12.     printf("}\n______________________________\n\n\n");
  13. }
  14. void remp(int *t,int n,char ch[],char c)
  15. {
  16.    printf("aight fill up the %s list:\n",ch);
  17.    for (int a=0; a<n;a++)
  18.    {
  19.        printf("%c[%d]: ",c,a);
  20.        scanf("%d",t+a);
  21.    }
  22. }
  23. int symetricDifference(int A[],int B[],int *C,int n,int m,int c)
  24. {
  25.     int b;
  26.     ///method one
  27.     for (int a=0;a<n;a++)
  28.     {
  29.         for ( b=0;b<m;b++)
  30.         {
  31.             if (A[a]==B[b])
  32.                 break;
  33.         }
  34.         if (b<m)
  35.             continue;
  36.         *(C+c) = A[a];
  37.         c++;
  38.     }
  39.     return c;
  40. }
  41. int main()
  42. {
  43.    int n,m;
  44.    printf("gimme N and M boi:\n");
  45.    scanf("%d%d",&n,&m);
  46.    int l=m+n;
  47.    int A[n],B[m],C[l];
  48.    remp(A,n,"first",'A');
  49.    remp(B,m,"second",'B');
  50.                                                                             //this is decoration a7guerha
  51.                                                                     system("cls");
  52.                                                                     system("color 3");
  53.    aff(A,n,'A');
  54.    aff(B,m,'B');
  55.    //putting the first half in welli heya A-B
  56.    l=symetricDifference(A,B,C,n,m,0);
  57.    //adding the second half welli heya B-A
  58.    l=symetricDifference(B,A,C,m,n,l);
  59.    aff(C,l,'C');
  60. }
  61.  
Add Comment
Please, Sign In to add comment