// ConsoleApplication1.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
/* int n;
cout << "n=" << endl;
cin >> n; */
int n = 4;
double a[4][5] = { {1,2,3,2,-1},{-1,2,2,1,0} ,{2,4,-2,2,4} ,{-1,3,2,2,0} };
for (int k = 0; k < n; k++)
{
int max = a[k][k];
// cout << a[k][k] << endl;
int r = k;
for (int i = 0; i < n; i++)
{
if (abs(a[i][k])>abs(max)) {
max = a[i][k];
r = i;
}
}
if (max == 0) {
cout << " Macierz układu osobliwa" << endl;
}
for (int j = k; j < n+1 ; j++) {
a[k][j] = a[r][j];
// cout << a[k][j] << endl;
}
for (int j = k; j < n+1; j++)
{
a[k][j] = a[k][j] / max;
cout << k << j << endl;
cout << a[k][j] << endl;
}
for (int i = 1; i < n; i++) {
if (i == k) {
continue;
}
for (int j = k; j < n+1; j++)
{
a[i][j] = a[i][j] - a[i][k] * a[k][j];
}
}
}
for (int i = 1; i < 4; i++)
{
for (int j = 1; i < 5; i++)
{
cout << a[i][j] << endl;
}
}
system("pause");
return 0;
}
{"html5":"htmlmixed","css":"css","javascript":"javascript","php":"php","python":"python","ruby":"ruby","lua":"text\/x-lua","bash":"text\/x-sh","go":"go","c":"text\/x-csrc","cpp":"text\/x-c++src","diff":"diff","latex":"stex","sql":"sql","xml":"xml","apl":"apl","asterisk":"asterisk","c_loadrunner":"text\/x-csrc","c_mac":"text\/x-csrc","coffeescript":"text\/x-coffeescript","csharp":"text\/x-csharp","d":"d","ecmascript":"javascript","erlang":"erlang","groovy":"text\/x-groovy","haskell":"text\/x-haskell","haxe":"text\/x-haxe","html4strict":"htmlmixed","java":"text\/x-java","java5":"text\/x-java","jquery":"javascript","mirc":"mirc","mysql":"sql","ocaml":"text\/x-ocaml","pascal":"text\/x-pascal","perl":"perl","perl6":"perl","plsql":"sql","properties":"text\/x-properties","q":"text\/x-q","scala":"scala","scheme":"text\/x-scheme","tcl":"text\/x-tcl","vb":"text\/x-vb","verilog":"text\/x-verilog","yaml":"text\/x-yaml","z80":"text\/x-z80"}