Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ConsoleApplication2.cpp : Defines the entry point for the console application.
- //
- #include "stdafx.h"
- #define MAX_SIZE 100
- int main()
- {
- int arr[MAX_SIZE], freq[MAX_SIZE];
- int size, i, j, count;
- printf("size:");
- scanf_s("%d", &size);
- printf("elements:");
- for (i = 0; i<size; i++)
- {
- scanf_s("%d", &arr[i]);
- freq[i] = -1;
- }
- /* тут считается к-во повторений элемента */
- for (i = 0; i<size; i++)
- {
- count = 1;
- for (j = i + 1; j<size; j++)
- {
- if (arr[i] == arr[j])
- {
- count++;
- freq[j] = 0;
- }
- }
- if (freq[i] != 0)
- {
- freq[i] = count;
- }
- }
- printf("\n unique: ");
- for (i = 0; i<size; i++)
- {
- if (freq[i] == 1)
- {
- printf("%d ", arr[i]);
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement