#include <iostream>
using namespace std;
int main()
{
double a[] ={2,2,2,
3,2,4,
1,3,9};
double b[] = {1,0.5,2.5};
double m =0;
int n=3;
for (int i = 0; i < n-1; i++)
{
for (int j = i + 1; j < n; j++)
{
m = a[j*n+i] / a[i*n+i];
b[j] = b[j] - m * b[i];
for (int k = i; k < n; k++)
{
a[j*n+k] = a[j*n+k] - m*a[i*n+k];
}
}
}
int deta=0;
int detb=0;
for (int i=0;i<n;i++)
{
if (b[i] == 0)
{
detb = i-1;
break;
}
}
if (detb ==0)
{
detb =2;
}
int tmp=0;
for (int i=0;i<n;i++)
{
for (int j=0;j<n;j++)
{
if (a[i*n+j] == 0 )
{
tmp++;
}
}
if (tmp == n)
{
deta = i-1;
break;
}
tmp =0;
}
if (tmp ==0)
{
deta=2;
}
for (int i=0;i<n;i++)
{
for (int j=0;j<n;j++)
{
cout<<a[i*n+j]<<"";
}
cout<<endl;
}
cout<<endl;
for (int i=0;i<n;i++)
{
cout<<b[i]<<"";
}
cout<<endl;
cout<<deta<<""<<detb<<endl;
if (deta < detb)
{
cout<<"no exit solution"<<endl;
}
else
{
cout<<"exit solution"<<endl;
}
system("pause");
return 0;
}