Тема: Неправильно працює програма
Як виправити цю дурню?
#include "stdafx.h"
#include <iostream>
#include <math.h>
#include <iomanip>
using namespace std;
int main()
{
int i, j;
unsigned N = 0, M = 0,A=0; //n -stolbci m -stroki b-svob el
cout << "M= "; cin >> M; cout << "N= "; cin >> N;
double ** arr = new double*[N];
for (i = 0; i < N; i++) {
arr[i] = new double[M];
for (j = 0; j < M; j++)
arr[i][j] = rand() % 10 - 5;
}
cout << "matrix A:\n";
for (i = 0; i<N; i++)
{
for (j = 0; j<M; j++)
cout << setw(7) << setprecision(2) << arr[i][j];
cout << "\n";
}
double **B = new double*[A];
cout << "Svobodni cleni matrix" << endl;
for (int i = 0; i < M; i++)
{
cout << "svob cl: " << "[" << i << "] = ";
cout << B[i];
cout << "\n";
}
int x = 0;
cout << endl << "lin rivnanya" << endl;
for (i = 0; i < M; i++)
for (j = 0; j < N; j++)
{
cout << arr[i][j] << "x" << ++x;
if (j != 2)
cout << " + ";
if (j == 2)
{
cout << " = " << B[i];
cout << endl;
}
}
cout << endl;
system("pause");
system("cls");
delete[] arr[i];
delete[] B[i];
system("pause");
return 0;
}