Semua yang terjadi dalam kehidupanku ataupun yang ada dalam pikiranku, akan ku tuangkan disini..
Thursday, 8 December 2011
Program Gauss Jordan
#include<stdio.h>
#include<iostream.h>
#include<conio.h>
#include<math.h>
void main()
{
float a[6][6],b[6],x[6],t,s;
int i,j,n,k;
cout<<"Enter the maximum no. of matrix"<<endl;
cin>>n;
cout<<"Enter th elements of matrix"<<endl;
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
cin>>a[i][j];}
}
cout<<"enter the right constant"<<endl;
for(i=0;i<n;i++)
{
cin>>a[i][n];}
for(k=0;k<n;k++)
{
for(i=0;i<n;i++)
if(i!=k)
{
for(j=k+1;j<n+1;j++)
{
a[i][j]=a[i][j]-(a[i][k]/a[k][k])*(a[k][j]);
}
}
}
cout<<"the solution is"<<endl;
for(i=0;i<n;i++)
{
x[i]=(a[i][n]/a[i][i]);
cout<<"x["<<i<<"]="<<x[i]<<endl;
}
getch();
}
Labels:
Trick C-free
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment