SHARE
TWEET

Untitled

a guest Oct 21st, 2019 65 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <time.h>
  2. #include <locale.h>
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5. #define SIZE 50
  6. int main()
  7. {
  8. int n, j, x, t, schetchik;
  9. x = 0;
  10. t = 0;
  11. schetchik = 0;
  12. signed int a[SIZE], b[SIZE];
  13. setlocale(LC_ALL, "rus");
  14. srand(time(0));
  15. puts("Введите количество элементов массива меньшее 50");
  16. scanf_s("%d", &n);
  17. if (n >= 50 || n <= 0) {
  18. puts("условие не выполнено");
  19. return(0);
  20. }
  21. for (int i = 0; i < n; i++)
  22. {
  23. a[i] = rand() % 12;
  24. printf_s("%10d", a[i]);
  25. }
  26. printf("");
  27. for (int i = 0; i < n; i++)
  28. {
  29. schetchik = 0;
  30. j = a[i];
  31. for (int i = 0; i < n; i++)
  32. 1
  33. {
  34. if (j == a[i])
  35. schetchik++;
  36. if (schetchik > 3)
  37. {
  38. for (int i = 0; i < n; i++)
  39. {
  40. if (a[i] == j)
  41. a[i] = INT_MAX;
  42. }
  43. }
  44. }//printf_s("%10d", a[i]);//вывод для проверки что числа обнуляются
  45. }
  46. printf("\n");
  47. puts("Новый массив");
  48. for (int i = 0; i < n - 1; i++)
  49. if (a[i] == INT_MAX)
  50. {
  51. a[i] = a[i + 1];
  52. a[i + 1] = INT_MAX;
  53. }
  54. for (int i = 0; i < n; i++)
  55. if (a[i] != INT_MAX)
  56. {
  57. b[x] = a[i];
  58. x++;
  59. }
  60. else t++;
  61. for (int x = 0; x < n - t; x++)
  62. printf_s("%10d", b[x]);
  63. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top