Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <math.h>
- #include <time.h>
- #include <string>
- using namespace std;
- int main() {
- setlocale(LC_ALL, "rus");
- srand(time(NULL));
- string ans = "";
- int n, data[100][100], k1, k2, cntk1 = 0, cntk2 = 0;
- cout << "Введите n: ";
- cin >> n;
- cout << "Исходный матрица: " << endl;
- for (int i = 0; i < n; i++) {
- for (int j = 0; j < n; j++) {
- data[i][j] = rand() % 20 - 10;
- cout << data[i][j] << ' ';
- }
- cout << endl;
- }
- cout << endl;
- cout << "Введите k1: ";
- cin >> k1;
- cout << "Введите k2: ";
- cin >> k2;
- for (int i = 0; i < n; i++) {
- for (int j = 0; j < n; j++) {
- if (data[i][j] > k1)
- cntk1++;
- if (data[i][j] < k2)
- cntk2++;
- }
- }
- if (cntk1 > cntk2)
- ans = "больше";
- else if (cntk1 < cntk2)
- ans = "меньше";
- else
- ans = "равно";
- cout << "Кол-во элементов превышающих k1 (" << cntk1 << ") " << ans << " чем не превышающих k2(" << cntk2 << ") ." << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement