Untitled

 avatar
unknown
c_cpp
2 years ago
1.2 kB
4
Indexable
#include <iostream>
using namespace std;

int main() {
	setlocale(LC_ALL, "Russian");
	int mas[5], sum = 0, max, min, countmax = 0, a, counta = 0;
	cout << "Введите а: ";
	cin >> a;
	cin >> mas[0];
	max = mas[0];
	min = mas[0];
	sum += mas[0];
	if (mas[0] > max) {
		max = mas[0];
	}
	if (mas[0] <= min) {
		min = mas[0];
	}
	for (int i = 1; i < 5; i++) {
		cin >> mas[i];
		sum += mas[i];
		if (mas[i] > max) {
			max = mas[i];
		}
		if (mas[i] <= min) {
			min = mas[i];
		}
	}
	for (int j = 0; j < 5; j++) {
		if (mas[j] == max) {
			countmax += 1;
		}
	}
	for (int j = 0; j < 5; j++) {
		if (mas[j] == a) {
			counta += 1;
		}
	}
	int mass[5];
	for (int j = 0; j < 5; j++) {
		mass[j] = mas[j];
	}
	cout << "Сумма: " << sum << endl;
	cout << "Максимальное число: " << max << endl;
	cout << "Минимальное число: " << min << endl;
	cout << "Количество максимальных чисел: " << countmax << endl;
	cout << "Сумма элементов равных а: " << counta << endl;
	for (int j = 0; j < 5; j++) {
		cout << "В другом массиве: ";
		cout << mass[j] << ' ';
	}
}
Editor is loading...
Leave a Comment