#include<iostream>
#include<iomanip>
using namespace std;
int main()
{
int i,j,k,n;
float a[10][10],x[10];
cout<<"Enter Order of Equation: ";
cin>>n;
cout<<"Enter Coefficients of Equation Row-wise\n";
for(i=1;i<=n;i++)
{
for(j=1;j<=n+1;j++)
cin>>a[i][j];
}
for(i=1;i<=n;i++)
{
for(j=1;j<=n;j++)
{
if(i!=j)
{
float s=a[j][i]/a[i][i];
for(k=1;k<=n+1;k++)
a[j][k]=a[j][k]-s*a[i][k];
}
}
}
cout<<"\nThe Solutions are:\n\n";
for(i=1;i<=n;i++)
{
cout<<"X"<<i<<"="<<a[i][n+1]/a[i][i]<<"\n";
}
return(0);
}
No comments:
Post a Comment