Помогите написать программу на C++
Приложения:

Ответы на вопрос
Ответил contrlc
0
#include <iostream>
using namespace std;
int main()
{
int matrix[4][4];
int n,m;
cout << "Введите размер матрицы n и m: ";
cin >> n >> m;
cout << "Введите матрицу " << n << "x" << m << ":n";
for (int i = 0; i < n; i++)
for(int j = 0; j < m; j++)
cin >> matrix[i][j];
cout << "Введенная матрица:" << endl;
for (int i = 0; i < n; i++)
{
for(int j = 0; j < m; j++)
cout << matrix[i][j] << " ";
cout << endl;
}
return 0;
}
using namespace std;
int main()
{
int matrix[4][4];
int n,m;
cout << "Введите размер матрицы n и m: ";
cin >> n >> m;
cout << "Введите матрицу " << n << "x" << m << ":n";
for (int i = 0; i < n; i++)
for(int j = 0; j < m; j++)
cin >> matrix[i][j];
cout << "Введенная матрица:" << endl;
for (int i = 0; i < n; i++)
{
for(int j = 0; j < m; j++)
cout << matrix[i][j] << " ";
cout << endl;
}
return 0;
}
Ответил bashmakov97
0
код программы правильный
Ответил clinteastwood2
0
#include <iostream>
#include <vector>
using namespace std;
const unsigned N = 4;
int main()
{
vector<vector<int>> matr(N, vector<int>(N, 5));
for (auto it = matr.begin(); it != matr.end(); ++it) {
for (const auto &i : *it) {
cout << i << " ";
}
cout << endl;
}
return 0;
}
#include <vector>
using namespace std;
const unsigned N = 4;
int main()
{
vector<vector<int>> matr(N, vector<int>(N, 5));
for (auto it = matr.begin(); it != matr.end(); ++it) {
for (const auto &i : *it) {
cout << i << " ";
}
cout << endl;
}
return 0;
}
Новые вопросы