Это "чистяк"! Т.е. расчитывается, что пользователь проги будет адекватным юзером и пихать корректную инфу в алгоритм...
<!--c1--><div class='codetop'>Код</div><div class='codemain'><!--ec1-->/*
for beta-test
2 4 3 2
5 1 2 3
4 2 1 3
4 2 3 1
*/
#include <iostream>
#include <conio>
int main()
{
///// n - stroka /////
///// m - stolbec /////
int n, m;
float M;
cout << "============" << endl;
cout << " Program Matrica " << endl;
cout << "============" << endl;
cout << endl;
cout << "Enter size of the matrix:" << endl;
cin >> n >> m;
float a['n']['m'];
cout << endl << "Enter elements of the matrix:" << endl << endl;
for (int i = 1; i <= n; i++)
{
for (int j = 1; j <= m; j++)
{
cout << "a[" << i << "][" << j << "]: ";
cin >> a[j];
}
}
cout << endl << endl << "Start-matrix:" << endl << endl;
for (int i = 1; i <= n; i++)
{
for (int j = 1; j <= m; j++)
cout << a[j] << " ";
cout << endl;
}
//----------------------PEKLO ZDES!----------------------
for (int i = 1; i < n; i++)
{
///// j < (i+1) - ishem /////
///// mnozhiteli pod glavnoi /////
///// diaganaliu matrici /////
for (int j = 1; j < (i+1); j++)
{
///// M - mnozhitel /////
///// elementa j stroki i+1 /////
M = -(a[i+1][j]/a[1][j]);
///// zanulenie elementa j /////
///// stroki i+1 /////
for (int mnozhj = j; mnozhj <= m; mnozhj++)
a[i+1][mnozhj] += M*a[1][mnozhj];
}
}
//-------------------------------------------------------
cout << endl << endl << "Finish-matrix:" << endl << endl;
for (int i = 1; i <= n; i++)
{
for (int j = 1; j <= m; j++)
cout << a[j] << " ";
cout << endl;
}
cout << endl << endl << "Press any key...";
getch();
return(0);
}<!--c2--></div><!--ec2-->