#include "stdafx.h"
#include <iostream>
#include <ctime>
using namespace std;
int main()
{
srand(time(0));
int n, m, k;
cout << "N = ";
cin >> n;
cout << "M = ";
cin >> m;
cout << "K = ";
cin >> k;
int A[100][100];
for (int i = 0; i < n; i++)
for (int j = 0; j < m; j++)
A[i][j] = 1 + rand() % 10; // от 1 до 10
}
cout << endl;
cout << A[i][j] << " ";
int temp = 0;
if (A[i][j] == k)
temp++;
cout << temp << endl;
system("pause");
return 0;
Copyright © 2024 SCHOLAR.TIPS - All rights reserved.
Answers & Comments
#include "stdafx.h"
#include <iostream>
#include <ctime>
using namespace std;
int main()
{
srand(time(0));
int n, m, k;
cout << "N = ";
cin >> n;
cout << "M = ";
cin >> m;
cout << "K = ";
cin >> k;
int A[100][100];
for (int i = 0; i < n; i++)
{
for (int j = 0; j < m; j++)
{
A[i][j] = 1 + rand() % 10; // от 1 до 10
}
}
cout << endl;
for (int i = 0; i < n; i++)
{
for (int j = 0; j < m; j++)
{
cout << A[i][j] << " ";
}
cout << endl;
}
int temp = 0;
for (int i = 0; i < n; i++)
{
for (int j = 0; j < m; j++)
{
if (A[i][j] == k)
temp++;
}
}
cout << temp << endl;
system("pause");
return 0;
}