Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using std::endl;
- using std::cout;
- using std::cin;
- int main()
- {
- int k, max, i, x, S;
- setlocale(LC_ALL, "Russian");
- cout << "Введите размер массива - ";
- cin >> k;
- int *arr = new int[k];
- cout << "Введите массив " << endl;
- for (i = 0; i < k; i++)
- {
- cout << "arr [" << i << "] = ";
- cin >> arr[i];
- }
- cout << "Введенный массив " << endl;
- cout << "arr = { ";
- for (i = 0; i < k; i++)
- {
- cout << arr[i] << " ";
- }
- cout << "}" << endl;
- max = arr[0];
- for (i = 0; i < k; i++)
- {
- if (arr[i] > max)
- {
- max = arr[i];
- }
- }
- S = 1;
- cout << "Максимальный элемент массива - " << max << endl;
- for (i = 0; i < k; i++)
- {
- if (arr[i] == 0)
- {
- i++;
- if (arr[i] == 0) { cout << "Между нулями нет чисел" << endl; break; }
- else
- {
- while (arr[i] != 0)
- {
- S *= arr[i];
- i++;
- }
- cout << "S = " << S << endl;
- }
- }
- }
- cout << "Отсортированный массив" << endl;
- cout << "{ ";
- for (int i = 0; i < k; i++)
- {
- if (i % 2 == 1)
- {
- cout << arr[i]<<" ";
- }
- }
- for (int i = 0; i < k; ++i)
- {
- if (i % 2 == 0)
- {
- cout << arr[i]<<" ";
- }
- }
- cout << "}";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement