Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "pch.h"
- #include <iostream>
- #include <Windows.h>
- #include <cmath>
- using namespace std;
- int main()
- {
- //setlocale(LC_ALL, "Russian");
- SetConsoleOutputCP(1251);
- SetConsoleCP(1251);
- long n;
- char ex = 'n';
- do {
- cout << "Введите номер задачи (1 или 2):\n";
- char task;
- cin.ignore(100, '\n');
- cin >> task;
- /*cout << "Введите n" << endl;
- cin.ignore(100, '\n');
- cin >> n;*/
- switch (task)
- {
- case '1':
- {
- int const n = 8, m = 10;
- int k;
- double mas[n][m];
- cout << "Enter k" << endl;
- cin >> k;
- cout << "Enter mas" << endl;
- for (int i = 0; i < n; i++)
- for (int j = 0; j < m; j++)
- //cin >> mas[i][j];
- mas[i][j] = rand() % 1000 / 100.0;
- for (int i = 0; i < n; i++) {
- for (int j = 0; j < m; j++) {
- cout << mas[i][j] << "\t";
- }
- cout << endl;
- }
- double max = mas[0][0];
- double maxk = mas[k - 1][0];
- for (int i = 0; i < n; i++)
- for (int j = 0; j < m; j++)
- if (mas[i][j] > max)
- max = mas[i][j];
- cout << "max = " << max << endl;
- for (int j = 0; j < m; j++)
- if (mas[k-1][j] > maxk)
- maxk = mas[k-1][j];
- cout << "maxk = " << maxk << endl;
- double r = maxk / max;
- cout << r << endl;
- }
- break;
- case '2':
- {
- int const n = 11;
- double mas[n][n];
- for (int i = 0; i < n; i++)
- for (int j = 0; j < n; j++)
- //cin >> mas[i][j];
- mas[i][j] = rand() % 100; // 100.0;
- cout << "mas:" << endl;
- for (int i = 0; i < n; i++) {
- for (int j = 0; j < n; j++) {
- cout << mas[i][j] << " ";
- }
- cout << endl;
- }
- for (int i = 0; i < 6; i++)
- {
- for (int j = 5+i; j < 11; j++) {
- mas[i][j] = 1;
- }
- }
- cout << "New mas" << endl;
- for (int i = 0; i < n; i++) {
- for (int j = 0; j < n; j++) {
- cout << mas[i][j] << " ";
- }
- cout << endl;
- }
- }
- break;
- default: {cout << "Нет такой задачи.\n"; } break;
- }
- cout << "Если вы хотите выйти, введите \'y\', в противном случае - любую другую клавишу" << endl;
- cin.ignore(100, '\n');
- cin >> ex;
- } while (ex != 'y');
- return 0;
- system("pause");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement