Guest User

Untitled

a guest
Oct 21st, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.31 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. double EnterMass(int n)
  5. {
  6. int i,A[10];
  7. for (i = 0; i < n; i++)
  8. {
  9. cin >> A[i];
  10. }
  11. return *A;
  12. }
  13.  
  14.  
  15. double ProssMass(int b, int n)
  16. {
  17. int i, j, k, f = 0, q = 0, w = 0, u = 0;
  18. int G[10], C[10], D[10], B[10];
  19. *G = EnterMass(n);
  20. j = 0;
  21. k = 0;
  22. for (i = 0; i < n; i++)
  23. {
  24. if (G[i] < b)
  25. {
  26. B[j] = G[i];
  27. j++;
  28. u++;
  29. }
  30. }
  31.  
  32. for (i = 0; i < n; i++)
  33. {
  34. if (G[i] == b)
  35. {
  36. C[k] = G[i];
  37. k++;
  38. q++;
  39. }
  40. }
  41.  
  42. for (i = 0; i < n; i++)
  43. {
  44. if (G[i] > b)
  45. {
  46. D[f] = G[i];
  47. f++;
  48. w++;
  49. }
  50. }
  51.  
  52. j = 0;
  53. for (i = u; i < u + q; i++)
  54. {
  55. B[i] = C[j];
  56. j++;
  57. }
  58. for (i = u + q; i < u + q + w; i++)
  59. {
  60. B[i] = D[k];
  61. k++;
  62. }
  63. return *B;
  64. }
  65.  
  66.  
  67.  
  68.  
  69. int main()
  70. {
  71. setlocale(LC_ALL, "rus");
  72. int n, b;
  73. cout << "Введите число элементов массива и число b:" << endl;
  74. cin >> n >> b;
  75. cout << "Введите массив:" << endl;
  76. int R[10]; *R = ProssMass(b, n);
  77. cout << "Преобразованный массив:" << endl;
  78. cout << R << endl;
  79. system("pause");
  80. return 0;
  81. }
Add Comment
Please, Sign In to add comment