Upload
john-carlo-magno
View
218
Download
0
Embed Size (px)
Citation preview
7/23/2019 TURBO C++ CODES FOR GAUSS SEIDEL
1/4
5x5 gauss seidel
#include
#include
void main()
{clrscr();
float x[4];
float y[4];
float z[4];
float u[4];
float w[4];
float ans[5] = {0,0,0,0,0};
int hehe = 1;
cout
7/23/2019 TURBO C++ CODES FOR GAUSS SEIDEL
2/4
cin>>z[a];
}
cout
7/23/2019 TURBO C++ CODES FOR GAUSS SEIDEL
3/4
{y[a] *= (con - x[b]);}
}
for(b = 0; b < point; b++)
{
if(a != b)
{y[a] /= (x[a] - x[b]);}}
}
for(a = 0; a < point; a++)
{ans += y[a];}
cout
7/23/2019 TURBO C++ CODES FOR GAUSS SEIDEL
4/4
Gauss-Seidel#include
#include
#include
#include
void main()
{
//Variables Declaration
double X, Y, Z, XN, YN, ZN;
int a11, a12, a13, C1;
int a21, a22, a23, C2;
int a31, a32, a33, C3;
int i;
//Initializing
i=0;
clrscr();
//Program Start
cout C2;
cout > a31;
cout > a32;
cout > a33;cout > C3;
//Initial Values
cout Y;
cout > Z;
//Program Proper (iterations)
do
{
i++;
printf("\nIteration %3d",i);
if (i > 1)
{
X=XN;
Y=YN;
Z=ZN;
}
XN=(C1-a12*Y-a13*Z)/a11;
YN=(C2-a21*XN-a23*Z)/a22;
ZN=(C3-a31*XN-a32*YN)/a33;
cout