Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "pch.h"
- #include <iostream>
- #include <cstdlib>
- #include <math.h>
- using namespace std;
- int main()
- {
- setlocale(LC_ALL, "RUS");
- int a[20], i, n, min, max, sum = 0;
- cout << "Введите количество элементов массива" << endl;
- cin >> n;
- if (n < 1 || n>20) {
- cout << "Ошибка,n не должен быть больше 20" << endl;
- system("pause");
- return 0;}
- for (i = 0; i < n; ++i) {
- cout << "a[" << i + 1 << "]=";
- cin >> a[i];}
- min = max = a[0];
- for (i = 0; i < n; ++i) {
- if (min > a[i]) min = a[i];
- else if (max < a[i]) max = a[i];}
- cout << "Min: " << min << endl;
- cout << "Max: " << max << endl;
- for (i=min; i < n; i++) {
- sum += a[i];
- }
- cout << "Сумма массива расположенных после минимального значения:" << sum << endl;
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement