Advertisement
ab_tanjir

Remove Duplicate Item - ABTanjir

Sep 27th, 2019
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.59 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int main(){
  4.   int n, a[100], b[100], count = 0, c, d;
  5.  
  6.   printf("Enter number of elements in array\n");
  7.   scanf("%d", &n);
  8.  
  9.   printf("Enter %d integers\n", n);
  10.  
  11.   for (c = 0; c < n; c++){
  12.     scanf("%d", &a[c]);
  13.   }
  14.  
  15.   for (c = 0; c < n; c++){
  16.     for (d = 0; d < count; d++){
  17.       if(a[c] == b[d]){
  18.         break;
  19.       }
  20.     }
  21.    
  22.     if (d == count){
  23.       b[count] = a[c];
  24.       count++;
  25.     }
  26.   }
  27.  
  28.   printf("Array obtained after removing duplicate elements:\n");
  29.  
  30.   for (c = 0; c < count; c++){
  31.     printf("%d\n", b[c]);
  32.   }
  33.  
  34.   return 0;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement