Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // array!.cpp :
- //
- #include <iostream>
- using namespace std;
- int main()
- {
- float sum = 0;
- int max = 0;
- int min = 10000;
- int multi = 1;
- int multi2 = 1;
- int sumBetweenNegative = 0;
- int arraySize;
- int array[10000];
- cout << "Please enter array size by one number " << endl;
- cin >> arraySize;
- array[1000] = arraySize;
- cout << "Please enter random negative numbers " << endl;
- // найти сумму отрицательных чисел
- for (int i = 0; i < arraySize; i++)
- {
- cin >> array[i];
- }
- for (int i = 0; i < arraySize; i++)
- {
- if (array[i] < 0) sum += array[i];
- }
- cout << "This is the sum " << sum << endl << endl;
- //найти произведение диапазона от минимального к максимальному числу
- cout << "Let\'s find the product form min to max diapazon\n enter numbers please" << endl;
- for (int i = 0; i < arraySize; i++)
- {
- cin >> array[i];
- }
- for (int i = 0; i < arraySize; i++)
- {
- if (max < array[i]) max = array[i];
- if (array[i] < min) min = array[i];
- }
- cout << "This is max = " << max << endl;
- cout << "This is min = " << min << endl << endl;
- for (int i = min; i < max; i++)
- {
- multi *= array[i];
- }
- cout << "This is product " << multi << endl;
- //произведение элементов с четными номерами
- for (int i = 0; i < arraySize; i++)
- {
- if (array[i] % 2 == 0)
- {
- multi2 *= array[i];
- }
- }
- cout << "This is multi of the parity numbers " << multi2 << endl << endl << endl;
- //сумма между отрицательными элементами
- int minus = 0;
- int minus2 = 0;
- cout << "Let\'s find the sum from the first minus number to the last minus number\nplease enter the array size and then the numbers" << endl;
- cin >> arraySize;
- array[1000] = arraySize;
- for (int i = 0; i < arraySize; i++)
- {
- cin >> array[i];
- }
- int k = 0, p = 0;
- for (int i = 0; i < arraySize; i++)
- {
- if (array[i] < 0)
- {
- minus2 = array[i];
- p = i;
- }
- }
- for (int i = arraySize; i > 0; i--)
- {
- if (array[i] < 0)
- {
- minus = array[i];
- k = i;
- }
- }
- for (int i = k + 1; i < p; i++)
- {
- sumBetweenNegative += array[i];
- }
- cout << "This is sum between negative " << sumBetweenNegative;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement