Advertisement
Guest User

Untitled

a guest
Nov 23rd, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.77 KB | None | 0 0
  1. // ConsoleApplication2.cpp : Defines the entry point for the console application.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #define MAX_SIZE 100
  6.  
  7. int main()
  8. {
  9.     int arr[MAX_SIZE], freq[MAX_SIZE];
  10.     int size, i, j, count;
  11.  
  12.     printf("size:");
  13.     scanf_s("%d", &size);
  14.     printf("elements:");
  15.     for (i = 0; i<size; i++)
  16.     {
  17.         scanf_s("%d", &arr[i]);
  18.         freq[i] = -1;
  19.     }
  20.  
  21.     /* тут считается к-во повторений элемента */
  22.     for (i = 0; i<size; i++)
  23.     {
  24.         count = 1;
  25.         for (j = i + 1; j<size; j++)
  26.         {
  27.             if (arr[i] == arr[j])
  28.             {
  29.                 count++;
  30.                 freq[j] = 0;
  31.             }
  32.         }
  33.  
  34.         if (freq[i] != 0)
  35.         {
  36.             freq[i] = count;
  37.         }
  38.     }
  39.  
  40.     printf("\n unique: ");
  41.     for (i = 0; i<size; i++)
  42.     {
  43.         if (freq[i] == 1)
  44.         {
  45.             printf("%d ", arr[i]);
  46.         }
  47.     }
  48.  
  49.     return 0;
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement