Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- double EnterMass(int n)
- {
- int i,A[10];
- for (i = 0; i < n; i++)
- {
- cin >> A[i];
- }
- return *A;
- }
- double ProssMass(int b, int n)
- {
- int i, j, k, f = 0, q = 0, w = 0, u = 0;
- int G[10], C[10], D[10], B[10];
- *G = EnterMass(n);
- j = 0;
- k = 0;
- for (i = 0; i < n; i++)
- {
- if (G[i] < b)
- {
- B[j] = G[i];
- j++;
- u++;
- }
- }
- for (i = 0; i < n; i++)
- {
- if (G[i] == b)
- {
- C[k] = G[i];
- k++;
- q++;
- }
- }
- for (i = 0; i < n; i++)
- {
- if (G[i] > b)
- {
- D[f] = G[i];
- f++;
- w++;
- }
- }
- j = 0;
- for (i = u; i < u + q; i++)
- {
- B[i] = C[j];
- j++;
- }
- for (i = u + q; i < u + q + w; i++)
- {
- B[i] = D[k];
- k++;
- }
- return *B;
- }
- int main()
- {
- setlocale(LC_ALL, "rus");
- int n, b;
- cout << "Введите число элементов массива и число b:" << endl;
- cin >> n >> b;
- cout << "Введите массив:" << endl;
- int R[10]; *R = ProssMass(b, n);
- cout << "Преобразованный массив:" << endl;
- cout << R << endl;
- system("pause");
- return 0;
- }
Add Comment
Please, Sign In to add comment