Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <time.h>
- #include <locale.h>
- #include <stdio.h>
- #include <stdlib.h>
- #define SIZE 50
- int main()
- {
- int n, j, x, t, schetchik;
- x = 0;
- t = 0;
- schetchik = 0;
- signed int a[SIZE], b[SIZE];
- setlocale(LC_ALL, "rus");
- srand(time(0));
- puts("Введите количество элементов массива меньшее 50");
- scanf_s("%d", &n);
- if (n >= 50 || n <= 0) {
- puts("условие не выполнено");
- return(0);
- }
- for (int i = 0; i < n; i++)
- {
- a[i] = rand() % 12;
- printf_s("%10d", a[i]);
- }
- printf("");
- for (int i = 0; i < n; i++)
- {
- schetchik = 0;
- j = a[i];
- for (int i = 0; i < n; i++)
- 1
- {
- if (j == a[i])
- schetchik++;
- if (schetchik > 3)
- {
- for (int i = 0; i < n; i++)
- {
- if (a[i] == j)
- a[i] = INT_MAX;
- }
- }
- }//printf_s("%10d", a[i]);//вывод для проверки что числа обнуляются
- }
- printf("\n");
- puts("Новый массив");
- for (int i = 0; i < n - 1; i++)
- if (a[i] == INT_MAX)
- {
- a[i] = a[i + 1];
- a[i + 1] = INT_MAX;
- }
- for (int i = 0; i < n; i++)
- if (a[i] != INT_MAX)
- {
- b[x] = a[i];
- x++;
- }
- else t++;
- for (int x = 0; x < n - t; x++)
- printf_s("%10d", b[x]);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement