Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "pch.h"
- #include <iostream>
- #include <cstdlib>
- #include "Windows.h"
- #include <string>
- using namespace std;
- bool p = true;
- void prog_1() {
- double n,j;
- cout << "Введите кол-во элементов массива" << endl;
- cin >> n;
- cout << "Введите элементы массива" << endl;
- if ((round(n) == n)&&(n>0)) {
- int *mass = new int[round(n)];
- for (int i = 0; i < n; i++)
- {
- j = 0;
- cin >> j;
- if (round(j) == j) {
- mass[i] = round(j);
- }
- else {
- p = false;
- return;
- }
- }
- for (int i = 0; i < n; i++)
- {
- if (mass[i] % 2 != 0) {
- mass[i]++;
- }
- }
- for (int i = 0; i < n; i++) {
- cout << mass[i] << "\t";
- }
- p = true;
- }
- else {
- p = false;
- return;
- }
- }
- void prog_2() {
- double j = 0;
- double t = 0;
- int countA = 0;
- int countB = 0;
- double massB[5];
- double massA[5];
- cout << "Введите элементы массива A" << endl;
- for (int i = 0; i < 5; i++)
- {
- cin >> massA[i];
- }
- cout << "Введите элементы массива B"<< endl;
- for (int i = 0; i < 5; i++)
- {
- cin >> massB[i];
- }
- cout << "Введите значение t" << endl;
- cin >> t;
- for (int i = 0; i < 5; i++)
- {
- if (massA[i] > t) {
- countB++;
- }
- if (massB[i] > t) {
- countB++;
- }
- }
- if (countA < countB) {
- for (int i = 0; i < 5; i++)
- {
- cout << massA[i] << "\t";
- }
- cout << endl;
- for (int i = 0; i < 5; i++)
- {
- cout << massB[i] << "\t";
- }
- }
- else {
- for (int i = 0; i < 5; i++)
- {
- cout << massB[i] << "\t";
- }
- cout << endl;
- for (int i = 0; i < 5; i++)
- {
- cout << massA[i] << "\t";
- }
- }
- p = true;
- }
- void prog_3() {
- double n;
- double u;
- cout << "Введите кол-во строк и столбцов массива" << endl;
- cin >> n;
- double sum = 0;
- if ((round(n) == n)&&(n>0)) {
- double **mass;
- mass = new double *[trunc(n)];
- for (int i = 0; i < n; i++)
- mass[i] = new double [trunc(n)];
- cout << "Введите элементы массива" << endl;
- for (int i = 0; i < n; i++)
- {
- for (int j = 0; j < n; j++)
- {
- cin >> u;
- mass[i][j] = u;
- }
- }
- for (int i = 0; i < n; i++)
- {
- for (int j = 0; j < n; j++)
- {
- if (i > j) {
- sum += mass[i][j];
- }
- }
- }
- p = true;
- cout << "Сумма элементов ниже гл. диагонали равна " << sum;
- }
- else {
- p = false;
- return;
- }
- }
- int main()
- {
- SetConsoleCP(1251);
- SetConsoleOutputCP(1251);
- do {
- prog_1();
- } while (p = false);
- cout << endl;
- do {
- prog_2();
- } while (p = false);
- cout << endl;
- do {
- prog_3();
- } while (p = false);
- cout << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement