gpt-3.5-turbo-0301· openai
WildChat-4.8M
Напиши программу на языке с++ которая создаст матрицу А размером М на Н и заполнить ее…
- User
Напиши программу на языке с++ которая создаст матрицу А размером М на Н и заполнить ее однозначными случайными числами от 0 до 9 при этом значения М и Н вводятся с клавиатуры
- Assistant
#include #include <stdlib.h> #include <time.h>
using namespace std;
int main() { int M, N; cout << "Enter the number of rows (M): "; cin >> M; cout << "Enter the number of columns (N): "; cin >> N;
int A[M][N]; srand(time(NULL)); for(int i = 0; i < M; i++) { for(int j = 0; j < N; j++) { A[i][j] = rand() % 10; } } cout << "Generated matrix A:" << endl; for(int i = 0; i < M; i++) { for(int j = 0; j < N; j++) { cout << A[i][j] << " "; } cout << endl; } return 0;}
- User
Напиши ее на библиотеке iostream и ctime
- Assistant
#include #include
using namespace std;
int main() { int M, N; cout << "Enter the number of rows (M): "; cin >> M; cout << "Enter the number of columns (N): "; cin >> N;
int A[M][N]; srand(time(NULL)); for(int i = 0; i < M; i++) { for(int j = 0; j < N; j++) { A[i][j] = rand() % 10; } } cout << "Generated matrix A:" << endl; for(int i = 0; i < M; i++) { for(int j = 0; j < N; j++) { cout << A[i][j] << " "; } cout << endl; } return 0;}
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.