Friday, 3 January 2014

Program Menghitung GLB (Gerak Lurus Beraturan) (DevC++)

Program Menghitung GLB (Gerak Lurus Beraturan) (DevC++)


#include <iostream>

using namespace std;

int waktu (int s,int v)
{
 int hasil;
 hasil = s / v;
 return hasil;
}

int main()
{
 int s,v,hasil;
 cout <<"MENENTUKAN WAKTU TEMPUH KENDARAAN"<<endl;
 cout <<"Masukkan nilai jarak : ";
 cin >> s;
 cout <<"Masukkan nilai kecepatan : ";
 cin >> v;
 hasil=waktu(s,v);
 cout <<"Hasil waktu tempuh = "<<hasil<<endl;
 cout << " " << endl ;
 cout << "----------Selamat Menggunakan Program Ini-------------" << endl;
 cout << "----------------Semoga bermanfaat-------------";
 return 0;

}

Hasil Compile




Program Menghitung GLBB (Gerak Lurus Berubah Beraturan) (DevC++)

Program Menghitung GLBB (Gerak Lurus Berubah Beraturan) (DevC++)



#include <iostream>
using namespace std;


float waktu (float vo,float vt,float a)
{
 float hasil;
 hasil = vt / (vo + a);
 return hasil;
}


int main()
{
 float vo,vt,a,hasil;
 cout <<"MENENTUKAN WAKTU TEMPUH KENDARAAN"<<endl;
 cout <<"Masukkan kecepatan awal : ";
 cin >> vo;
 cout <<"Masukkan kecepatan akhir : ";
 cin >> vt;
 cout <<"Masukkan percepatan : ";
 cin >> a;
 hasil=waktu(vo,vt,a);
 cout <<"Hasil waktu tempuh = "<<hasil<<endl;
 cout << " " << endl ;
 cout << "----------Selamat Mencoba Program Ini-------------" << endl;
 cout << "---------------Semoga bermanfaat-------------";
 return 0;

}


Hasil Compile




Program Mencari Bilangan Positif dan Negatif ( Dev C++ )

Program Mencari Bilangan Positif dan Negatif ( Dev C++ )



#include<iostream>

using namespace std;

int main ()

{int x;
cout<<"monggo masukan bilangan bulat : " ;cin>>x;
if (x<0)
cout<<"itu Bilangan Negatif broo";
if (x>0)
cout<<"itu Bilangan Positif broo";
}

Hasil Compile 



Program Mencari Nilai Daya Listrik ( Dev C++ )

Program Mencari Nilai Daya Listrik ( Dev C++ )



#include <iostream>

#include <conio.h>

#include <stdio.h>

using namespace std;

int main(void )

{



float vs,r1,r2,r3,i1,i2,i3,pr1,pr2,pr3,i,rt,hubungan;

char mengulang;

do

{



cout<<"masukan nilai vs=";cin>>vs;

cout<<"masukan nilai r1=";cin>>r1;

cout<<"masukan nilai r2=";cin>>r2;

cout<<"masukan nilai r3=";cin>>r3;

do

{



cout<<"masukan hubungan r"<<endl;

cout<<"1.seri"<<endl<<"2.paralel"<<endl;

cout<<endl<<"apa hubungannya=>";cin>>hubungan;

if (hubungan==1)

{

rt=r1+r2+r3;

i=vs/rt;

i1=i2=i3=i;

pr1=i*i*r1;

pr2=i*i*r2;

pr3=i*i*r3;

}

else if(hubungan==2)

{

i1=vs/r1;

i2=vs/r2;

i3=vs/r3;

pr1=i1*i1*r1;

pr2=i2*i2*r2;

pr3=i3*i3*r3;

}

else

cout<<endl<<"maaf hubungan anda terlarang"<<endl<<"press any key";

getch();

cout<<"i1="<<i1<<endl;

cout<<"i2="<<i2<<endl;

cout<<"i3="<<i3<<endl;

cout<<"pr1="<<pr1<<endl;

cout<<"pr2="<<pr2<<endl;

cout<<"pr3="<<pr3<<endl;

}while(hubungan<1|hubungan>2);

cout<<"anda mau mengulang (Y/T)";cin>>mengulang;

}while(mengulang=='y');

cout<<"terima kasihku untukmu";

getch();

}

Hasil Compile


Metode Numerik ( Dev C++ )

Metode Numerik ( Dev C++ )



#include <cstdlib>
#include <iostream>
#include <math.h>
#include<conio.h>
#include <stdlib.h>
#include <Windows.h>
#include<iomanip>

using namespace std;
void head(){ 
cout<<"\n =============================";
cout<<"\n QUIZ METODE NUMERIK";
cout<<"\n =============================";
cout<<"\n Agri Kuswandani";
cout<<"\n =============================\n";
}
void RegresiLinier(int n);
void RegresiNonLinier(int n);
void AnalisisRegresiPolinomial(int n);
void SistemPersLinier(int n);
int main()
{
char pil,plh;
int n;
system("cls");
head();
cout<<"\n Masukkan Jumlah Data yang akan diinputkan : ";cin>>n;
cout<<"\n [ 1 ] Metode Regresi Linier\n"
" [ 2 ] Metode Regresi Non Linier\n"
" [ 3 ] Analisis Regresi Polinomial\n"
" [ 4 ] Sistem Persamaan Linier\n"
" [ 0 ] Exit\n"
  "\n Silahkan Pilih Metode Yang digunakan : ";cin>>pil;
switch(pil){
case '1':
system("cls");
RegresiLinier(n);
break;
case '2':system("cls");RegresiNonLinier(n);
break;
case '3':AnalisisRegresiPolinomial(n);
break;
case '4':SistemPersLinier(n);
break;
case '0':
exit(0);
break;
  }
system("pause");
return 0;
}
void RegresiLinier(int q){
system("cls");
long jumx=0,jumy=0,jumxy=0,jumxx=0,xy=0,xx=0,X,Y;
int n=q;
long ratx,raty,a,b;
float x[100],y[100];
cout<<"\n -------------";
cout<<"\n Input Data";
cout<<"\n -------------";
for (int h=1;h<=n;h++){
cout<<"\nNilai x"<<h<<" = ";cin>>x[h];
}cout<<"\n\n -------------";
for(int k=1;k<=n;k++){
cout<<"\nNilai y"<<k<<" = ";cin>>y[k];
}
system("cls");
cout<<"\n ===================================================================";
cout<<"\n | Data ke  |   X   |      Y      |       XY      |       X^2      |";
cout<<"\n ===================================================================\n";
for(int i=1;i<=n;i++){
jumx=jumx+x[i];
jumy=jumy+y[i];
xy=(x[i]*y[i]);
xx=(x[i]*x[i]);
jumxy=jumxy+xy;
jumxx=jumxx+xx;
cout<<"  "<<setiosflags(ios::left)<<setw(13)<<i;
cout<<setiosflags(ios::left)<<setw(11)<<x[i];
cout<<setiosflags(ios::left)<<setw(16)<<y[i];
cout<<setiosflags(ios::left)<<setw(16)<<xy;
cout<<setiosflags(ios::left)<<setw(11)<<xx;
cout<<"\n\n";
}
cout<<" -------------------------------------------------------------------\n";
cout<<"  "<<setiosflags(ios::left)<<setw(13)<<"JUMLAH";
cout<<setiosflags(ios::left)<<setw(11)<<jumx;
cout<<setiosflags(ios::left)<<setw(16)<<jumy;
cout<<setiosflags(ios::left)<<setw(16)<<jumxy;
cout<<setiosflags(ios::left)<<setw(11)<<jumxx;
cout<<"\n ===================================================================";
ratx=jumx/n;
raty=jumy/n;
b=((jumxy*n)-(jumx*jumy))/((jumxx*n)-(jumx*jumx));
a=raty-(b*ratx);
cout<<"\n Nilai Rata - Rata x = "<<ratx;
cout<<"\n Nilai Rata -  Rata y = "<<raty;
cout<<"\n Nilai b = "<<b;
cout<<"\n Nilai a = "<<a;
cout<<"\n\n Jadi Persamaanya adalah Y = "<<a<<" + "<<b<<" X";
cout<<"\n\n Masukkan Nilai taksiran untuk X = ";cin>>X;
Y=a+(b*X);
cout<<"\n untuk Taksiran x="<<X<<", maka nilai Y = "<<Y;
getch();main();
}
void RegresiNonLinier(int q){
system("cls");
int n=q;
float x[100],y[100];
float qi=0,pi=0,qipi=0,qi2=0,jumpi=0,jumqi=0,jumqipi=0,jumqiqi=0;
float ratqi,ratpi,B,A,P,a,b;
/*  ---------------Tranformasi Dengan log --------------------------*/
cout<<"\n -------------";
cout<<"\n Input Data";
cout<<"\n -------------";
for (int h=1;h<=n;h++){
cout<<"\nNilai x"<<h<<" = ";cin>>x[h];
}cout<<"\n\n -------------";
for(int k=1;k<=n;k++){
cout<<"\nNilai y"<<k<<" = ";cin>>y[k];
}
system("cls");
cout<<"\n =====================Tabel Penolong Dengan Log =====================";
cout<<"\n ===================================================================\n";
cout<<" "<<setiosflags(ios::left)<<setw(9)<<" No."<<setw(7)<<" xi "<<setw(7)<<" yi";
cout<<setiosflags(ios::left)<<setw(12)<<"qi=log xi"<<setw(12)<<"pi=log yi"<<setw(12)<<"qi.pi";
cout<<setiosflags(ios::left)<<setw(12)<<"qi^2";
cout<<"\n ===================================================================\n";
for(int i=1;i<=n;i++){
qi=log10(x[i]);
pi=log10(y[i]);
qipi=(qi*pi);
qi2=(qi*qi);
jumpi=jumpi+pi;
jumqi=jumqi+qi;
jumqipi=jumqipi+qipi;
jumqiqi=jumqiqi+qi2;
cout<<" "<<setiosflags(ios::left)<<setw(9)<<i;
cout<<setiosflags(ios::left)<<setw(7)<<x[i];
cout<<setiosflags(ios::left)<<setw(7)<<y[i];
cout<<setiosflags(ios::left)<<setw(12)<<qi;
cout<<setiosflags(ios::left)<<setw(12)<<pi;
cout<<setiosflags(ios::left)<<setw(12)<<qipi;
cout<<setiosflags(ios::left)<<setw(12)<<qi2;
cout<<"\n\n";
}
cout<<" -------------------------------------------------------------------\n";
cout<<"  "<<setiosflags(ios::left)<<setw(22)<<"JUMLAH";
cout<<setiosflags(ios::left)<<setw(12)<<jumqi;
cout<<setiosflags(ios::left)<<setw(12)<<jumpi;
cout<<setiosflags(ios::left)<<setw(12)<<jumqipi;
cout<<setiosflags(ios::left)<<setw(12)<<jumqiqi;
cout<<"\n ===================================================================";
ratqi=jumqi/n;
ratpi=jumpi/n;
B=((n*jumqipi)-(jumqi*jumpi))/((n*jumqiqi)-(jumqi*jumqi));
A=ratpi-(B*ratqi);
cout<<"\n\n Nilai Rata-rata qi : "<<ratqi;
cout<<"\n Nilai Rata-rata pi : "<<ratpi;
cout<<"\n Nilai B : "<<B;
cout<<"\n Nilai A : "<<A;
cout<<"\n Jadi Persamaan Transformasi Log-nya adalah : ";
cout<<A<<" + "<<B<<" q\n";
cout<<"\n Karena A log a ----> "<<A<<" = log a\n";
a=pow(10,A);
b=B;
cout<<"\n Maka Nilai a : "<<a;
cout<<"\n Maka Persamaan yang dicari adalah : \n";
cout<<"\n y = "<<a<<" X^"<<b<<endl;
/*  ---------------Tranformasi Dengan ln --------------------------*/
float fqi=0,fpi=0,fqipi=0,fqi2=0,fjumpi=0,fjumqi=0,fjumqipi=0,fjumqiqi=0;
float fratqi,fratpi,fB,fA,fP,fa,fb;
cout<<"\n\n";
cout<<"\n =====================Tabel Penolong Dengan Ln =====================";
cout<<"\n ===================================================================\n";
cout<<" "<<setiosflags(ios::left)<<setw(9)<<" No."<<setw(7)<<" xi "<<setw(7)<<" yi";
cout<<setiosflags(ios::left)<<setw(12)<<"qi=xi"<<setw(12)<<"pi=ln yi"<<setw(12)<<"qi.pi";
cout<<setiosflags(ios::left)<<setw(12)<<"qi^2";
cout<<"\n ===================================================================\n";
for(int i=1;i<=n;i++){
fqi=(x[i]);
fpi=logf(y[i]);
fqipi=(fqi*fpi);
fqi2=(fqi*fqi);
fjumpi=fjumpi+fpi;
fjumqi=fjumqi+fqi;
fjumqipi=fjumqipi+fqipi;
fjumqiqi=fjumqiqi+fqi2;
cout<<" "<<setiosflags(ios::left)<<setw(9)<<i;
cout<<setiosflags(ios::left)<<setw(7)<<x[i];
cout<<setiosflags(ios::left)<<setw(7)<<y[i];
cout<<setiosflags(ios::left)<<setw(12)<<fqi;
cout<<setiosflags(ios::left)<<setw(12)<<fpi;
cout<<setiosflags(ios::left)<<setw(12)<<fqipi;
cout<<setiosflags(ios::left)<<setw(12)<<fqi2;
cout<<"\n\n";
}
cout<<" -------------------------------------------------------------------\n";
cout<<"  "<<setiosflags(ios::left)<<setw(22)<<"JUMLAH";
cout<<setiosflags(ios::left)<<setw(12)<<fjumqi;
cout<<setiosflags(ios::left)<<setw(12)<<fjumpi;
cout<<setiosflags(ios::left)<<setw(12)<<fjumqipi;
cout<<setiosflags(ios::left)<<setw(12)<<fjumqiqi;
cout<<"\n ===================================================================";
fratqi=fjumqi/n;
fratpi=fjumpi/n;
B=((n*fjumqipi)-(fjumqi*fjumpi))/((n*fjumqiqi)-(fjumqi*fjumqi));
fA=fratpi-(fB*fratqi);
cout<<"\n\n Nilai Rata-rata qi : "<<fratqi;
cout<<"\n Nilai Rata-rata pi : "<<fratpi;
cout<<"\n Nilai B : "<<fB;
cout<<"\n Nilai A : "<<fA;
cout<<"\n Jadi Persamaan Transformasi Log-nya adalah : ";
cout<<fA<<" + "<<fB<<" q\n";
cout<<"\n Karena A= ln a ----> "<<fA<<" = ln a\n";
fa=pow(10,A);
fb=fB;
cout<<"\n Maka Nilai a : "<<fa;
cout<<"\n Maka Persamaan yang dicari adalah : \n";
cout<<"\n y = "<<fa<<" X^"<<fb<<endl;
getch();main();
}
void AnalisisRegresiPolinomial(int q){
system("cls");
float jumx=0,jumy=0,jumxy=0,jumxx=0,jumxxx=0,jumxxxx=0,jumx2y=0,xy=0,xx=0,X,Y,xxx=0,xxxx=0,x2y=0;
float ratx,raty,a,b;float L[3][3],U[3][3];float A[3][3];float B[3][3];
float y0=0,y1=0,y2=0,a0=0,a1=0,a2=0;
int n=q;
float x[100],y[100];
cout<<"\n -------------";
cout<<"\n Input Data";
cout<<"\n -------------";
for (int h=1;h<=n;h++){
cout<<"\nNilai x"<<h<<" = ";cin>>x[h];
}cout<<"\n\n -------------";
for(int k=1;k<=n;k++){
cout<<"\nNilai y"<<k<<" = ";cin>>y[k];
}
system("cls");
cout<<"\n ==================================================================="
  "===========================\n";
cout<<" "<<setiosflags(ios::left)<<setw(13)<<" Data ke-"<<setw(12)<<" x "<<setw(12)<<" y";
cout<<setiosflags(ios::left)<<setw(12)<<"xi^2"<<setw(12)<<" xi^3 "<<setw(12)<<"xi^4";
cout<<setiosflags(ios::left)<<setw(12)<<"xiyi"<<setw(12)<<" xi^2yi ";
cout<<"\n ==================================================================="
  "===========================\n";
for(int i=1;i<=n;i++){
jumx=jumx+x[i];
jumy=jumy+y[i];
xy=(x[i]*y[i]);
xx=(x[i]*x[i]);
xxx=(x[i]*x[i]*x[i]);
xxxx=(x[i]*x[i]*x[i]*x[i]);
 x2y=(xx*y[i]);
jumxy=jumxy+xy;
jumxx=jumxx+xx;
jumxxx=jumxxx+xxx;
jumxxxx=jumxxxx+xxxx;
 jumx2y=jumx2y+x2y;
cout<<"  "<<setiosflags(ios::left)<<setw(13)<<i;
cout<<setiosflags(ios::left)<<setw(12)<<x[i];
cout<<setiosflags(ios::left)<<setw(12)<<y[i];
cout<<setiosflags(ios::left)<<setw(12)<<xx;
cout<<setiosflags(ios::left)<<setw(12)<<xxx;
cout<<setiosflags(ios::left)<<setw(12)<<xxxx;
cout<<setiosflags(ios::left)<<setw(12)<<xy;
cout<<setiosflags(ios::left)<<setw(12)<<x2y;
cout<<"\n\n";
}
cout<<" ---------------------------------------------------------------------"
  "-------------------------\n";
cout<<"  "<<setiosflags(ios::left)<<setw(13)<<"Jumlah";
cout<<setiosflags(ios::left)<<setw(12)<<jumx;
cout<<setiosflags(ios::left)<<setw(12)<<jumy;
cout<<setiosflags(ios::left)<<setw(12)<<jumxx;
cout<<setiosflags(ios::left)<<setw(12)<<jumxxx;
cout<<setiosflags(ios::left)<<setw(12)<<jumxxxx;
cout<<setiosflags(ios::left)<<setw(12)<<jumxy;
cout<<setiosflags(ios::left)<<setw(12)<<jumx2y;
cout<<"\n=============================================="
  "===========================\n";
cout<<"\n\n Sistem Persamaan Sebagai berikut : \n";
cout<<"a0 + "<<jumx<<"a1 + "<<jumxx<<"a2 = "<<jumy<<endl;
cout<<jumx<<"a0 + "<<jumxx<<"a1 + "<<jumxxx<<"a2 = "<<jumxy<<endl;
cout<<jumxx<<"a0 + "<<jumxxxx<<"a1 + "<<jumxxxx<<"a2 = "<<jumx2y<<endl;
cout<<"\n ==================================================================="
  "===========================\n";
cout<<"\n ==========METODE LU============";
cout<<"\n ==================================================================="
  "===========================\n";
//-------Metode LU----------//
A[1][1]=n;A[1][2]=jumx;A[1][3]=jumxx;
A[2][1]=jumx;A[2][2]=jumxx;A[2][3]=jumxxx;
A[3][1]=jumxx;A[3][2]=jumxxx;A[3][3]=jumxxxx;

// mencari nilai Lii=Aii untuk i=1,2,3
L[1][1]=A[1][1];
L[2][1]=A[2][1];
L[3][1]=A[3][1];

U[1][2]=A[1][2]/L[1][1];
U[1][3]=A[1][3]/L[1][1];

L[2][2]=A[2][2]-(L[2][1]*U[1][2]);
L[3][2]=A[3][2]-(L[3][1]*U[1][2]);

U[2][3]=(A[2][3]-(L[2][1]*U[1][3]))/L[2][2];

L[3][3]=A[3][3]-((L[3][1]*U[1][3])-(L[3][2]*U[2][3]));

L[1][2]=0;L[1][3]=0;L[2][3]=0;

U[1][1]=1;U[2][2]=1;U[3][3]=U[2][2];
U[2][1]=0;U[3][1]=0;U[3][2]=0;

B[1][1]=jumx;B[1][2]=0;B[1][3]=0;
B[2][1]=jumxy;B[2][2]=0;B[2][3]=0;
B[3][1]=jumx2y;B[3][2]=0;B[3][3]=B[1][2];

cout<<"\n\n Matrik A : \n";
for (int i=1;i<=3;i++){
for(int j=1;j<=3;j++){
cout<<setiosflags(ios::right)<<setw(12)<<A[i][j];}
cout<<endl;}
cout<<"\n\n Matrik L : \n";
for (int i=1;i<=3;i++){
for(int j=1;j<=3;j++){
cout<<setiosflags(ios::right)<<setw(12)<<L[i][j];}
cout<<endl;}
cout<<"\n\n Matrik U : \n";
for (int i=1;i<=3;i++){
for(int j=1;j<=3;j++){
cout<<setiosflags(ios::right)<<setw(12)<<U[i][j];}
cout<<endl;}
cout<<"\n\n A=LU\n"
" Ax = b\n"
" LUx = b\n";
cout<<"\n\n Jadi Diadapat Persamaan.\n";
cout<<" "<<L[1][1]<<" y0 = "<<B[1][1];
cout<<"\n "<<L[2][1]<<" y0 + "<<L[2][2]<<" y1 = "<<B[2][1];
cout<<"\n "<<L[3][1]<<" y0 + "<<L[3][2]<<" y1 + "<<L[3][3]<<" = "<<B[3][1]<<endl;

y0=B[1][1]/L[1][1];
y1=(B[2][1]-(L[2][1]*y0))/L[2][2];
y2=(B[3][1]-((L[3][1]*y0)+(L[3][2]*y1)))/L[3][3];

cout<<"\n\n Jadi Diadapat Persamaan.\n";
cout<<"\n "<<U[1][1]<<" a0 + "<<U[1][2]<<" a1 + "<<U[1][3]<<" a2 = "<<y0;
cout<<"\n "<<U[2][2]<<" a1 + "<<U[2][3]<<" a2 = "<<y1;
cout<<"\n "<<U[3][3]<<" a2 = "<<y2<<endl;

a2=y2;
a1=(y1-(U[2][3]*a2))/U[2][2];
a0=(y0-(U[1][2]*a1)+(U[1][3]*a2))/U[1][1];

cout<<"\n\n Semua nilai a0,a1,a2 ke persamaan garis kurva.\n";

cout<<"\n E(i)^2 = (y-a0 -a1xi -a2xi^2)\n";
cout<<"\n = Y - "<<a0<<"- "<<a1<<"xi - "<<a2<<"xi^2"<<endl;
cout<<"\n Y = "<<a0<<" + "<<a1<<"x + "<<a2<<"x^2"<<endl;

cout<<"\n ==================================================================="
  "===========================\n";
cout<<"\n ==========ELIMINASI============";
cout<<"\n ==================================================================="
  "===========================\n";
///metode Eliminasi---
cout<<"\n\n\n";
cout<<n<<"a0 + "<<jumx<<"a1 + "<<jumxx<<"a2 = "<<jumy<<" ------------(1)\n";
cout<<jumx<<"a0 + "<<jumxx<<"a1 + "<<jumxxx<<"a2 = "<<jumxy<<" ------------(2)\n";
cout<<jumxx<<"a0 + "<<jumxxxx<<"a1 + "<<jumxxxx<<"a2 = "<<jumx2y<<" ------------(3)\n";
cout<<"\n ============================";
cout<<"\n Eliminasi Pers. 1 dan 2\n";
cout<<n<<"a0 + "<<jumx<<"a1 + "<<jumxx<<"a2 = "<<jumy<<endl;
cout<<jumx<<"a0 + "<<jumxx<<"a1 + "<<jumxxx<<"a2 = "<<jumxy<<endl;
cout<<"\n ============================\n";
float fa[10],fb[10],fc[10],fd[10],ha[5],hb[5],hc[5],hd[5];

fa[1]=n;fb[1]=jumx;fc[1]=jumxx;fd[1]=jumy;

fa[2]=jumx;fb[2]=jumxx;fc[2]=jumxxx;fd[2]=jumxy;

fa[3]=jumxx;fb[3]=jumxxx;fc[3]=jumxxxx;fd[3]=jumxy;

///eliminasi pers.1 dan 2
ha[1]=fa[1]*fa[2];
hb[1]=fb[1]*fa[2];
hc[1]=fc[1]*fa[2];
hd[1]=fd[1]*fa[2];

ha[2]=fa[2]*fa[1];
hb[2]=fb[2]*fa[1];
hc[2]=fc[2]*fa[1];
hd[2]=fd[2]*fa[1];


ha[3]=ha[1]-ha[2];//pers.4--->udah nilai 0
hb[3]=hb[1]-hb[2];
hc[3]=hc[1]-hc[2];
hd[3]=hd[1]-hd[2];
cout<<"\n ============================";
cout<<"\n Persamaan 4\n";
cout<<"   *"<<ha[3]<<" a0 + "<<hb[3]<<" a1 + "<<hc[3]<<" a2 = "<<hd[3]<<endl;
cout<<"\n ============================\n";
//eliminasi pers.1.dan pers.3
cout<<"\n ============================";
cout<<"\n Eliminasi Pers. 1 dan 3\n";
cout<<fa[1]<<" a0 + "<<fb[1]<<" a1 + "<<fc[1]<<" a2 = "<<fd[1]<<endl;
cout<<fa[3]<<" a0 + "<<fb[3]<<" a1 + "<<fc[3]<<" a2 = "<<fd[3]<<endl;
cout<<"\n ============================\n";
ha[4]=fa[1]*fa[3];
hb[4]=fb[1]*fa[3];
hc[4]=fc[1]*fa[3];
hd[4]=fd[1]*fa[3];

ha[5]=fa[3]*fa[1];
hb[5]=fb[3]*fa[1];
hc[5]=fc[3]*fa[1];
hd[5]=fd[3]*fa[1];


fa[4]=ha[4]-ha[5];//pers.5---->udah nilai 0
fb[4]=hb[4]-hb[5];
fc[4]=hc[4]-hc[5];
fd[4]=hd[4]-hd[5];
cout<<"\n ============================";
cout<<"\n Persamaan 5\n";
cout<<"   *"<<fa[4]<<" a0 + "<<fb[4]<<" a1 + "<<fc[4]<<" a2 = "<<fd[4]<<endl;
cout<<"\n ============================\n";
//eliminasi pers. 4 dan 5
cout<<"\n ============================";
cout<<"\n Eliminasi Pers. 4 dan 5\n";
cout<<ha[3]<<" a0 + "<<hb[3]<<" a1 + "<<hc[3]<<" a2 = "<<hd[3]<<endl;
cout<<fa[4]<<" a0 + "<<fb[4]<<" a1 + "<<fc[4]<<" a2 = "<<fd[4]<<endl;
cout<<"\n ============================\n";
fb[5]=hb[3]*fb[4];
fc[5]=hc[3]*fb[4];
fd[5]=hd[5]*fb[4];

fb[6]=fb[4]*hb[3];
fc[6]=fc[4]*hb[3];
fd[6]=fd[4]*hb[3];

fb[7]=fb[5]-fb[6];
fc[7]=fc[5]-fc[6];
fd[7]=fd[5]-fd[6];
cout<<"\n ============================";
cout<<"\n Persamaan 6( HASIL)\n";
cout<<fa[7]<<" a0 + "<<fb[7]<<" a1 + "<<fc[7]<<" a2 = "<<fd[7]<<endl;
cout<<"\n ============================\n";
a2=fd[7]/fc[7];
cout<<"\n ----------> Nilai a2 = "<<a2<<endl;
cout<<"\n Masukkan nilai a2 ke pers.4\n";

 a1 = (hd[3]-(hc[3]*a2))/hb[3];
cout<<"\n ----------> Nilai a1 = "<<a1<<endl;

cout<<"\n Masukkan Nilai a1 dan a2 ke pers. 1\n";
a0 = (fd[1]- ((fb[1]*a1) + (fc[1]*a2)))/fa[1];

cout<<"\n ----------> Nilai a0 = "<<a0<<endl;

cout<<"\n\n Kemudian masukkan a0,a1,a2 ke Persemaan grais kurva ,yaitu\n";
cout<<"\n E(i)^2 = (y - a0 - a1xi - a2xi^2)\n";
cout<<"\n\n Jadi Persamaan kurva orde duanya adalah \n";
cout<<" y = "<<a0<<" - "<<a1<<" xi - "<<a2<<" xi^2"<<endl;








getch();main();
}

void SistemPersLinier(int q){
system("cls");
int n=q;
float A[3][3],B[3][3],L[3][3],U[3][3];
float y1=0,y2=0,y3=0,x1=0,x2=0,x3=0;
A[1][1]=3;A[1][2]=-1;A[1][3]=2;
A[2][1]=1;A[2][2]=2;A[2][3]=3;
A[3][1]=2;A[3][2]=-2;A[3][3]=-1;
/* ---   Metode Lu------*/
B[1][1]=12;B[1][2]=0;B[1][3]=0;
B[2][1]=11;B[2][2]=0;B[2][3]=0;
B[3][1]=2;B[3][2]=0;B[3][3]=B[1][2];
L[1][1]=A[1][1];
L[2][1]=A[2][1];
L[3][1]=A[3][1];

U[1][2]=A[1][2]/L[1][1];
U[1][3]=A[1][3]/L[1][1];

L[2][2]=A[2][2]-(L[2][1]*U[1][2]);
L[3][2]=A[3][2]-(L[3][1]*U[1][2]);

U[2][3]=(A[2][3]-(L[2][1]*U[1][3]))/L[2][2];

L[3][3]=A[3][3]-((L[3][1]*U[1][3])-(L[3][2]*U[2][3]));

L[1][2]=0;L[1][3]=0;L[2][3]=0;

U[1][1]=1;U[2][2]=1;U[3][3]=U[2][2];
U[2][1]=0;U[3][1]=0;U[3][2]=0;



cout<<"\n\n Matrik A : \n";
for (int i=1;i<=3;i++){
for(int j=1;j<=3;j++){
cout<<setiosflags(ios::right)<<setw(12)<<A[i][j];}
cout<<endl;}
cout<<"\n\n Matrik B : \n";
for (int i=1;i<=3;i++){
for(int j=1;j<=3;j++){
cout<<setiosflags(ios::right)<<setw(12)<<B[i][j];}
cout<<endl;}
cout<<"\n\n Matrik L : \n";
for (int i=1;i<=3;i++){
for(int j=1;j<=3;j++){
cout<<setiosflags(ios::right)<<setw(12)<<L[i][j];}
cout<<endl;}
cout<<"\n\n Matrik U : \n";
for (int i=1;i<=3;i++){
for(int j=1;j<=3;j++){
cout<<setiosflags(ios::right)<<setw(12)<<U[i][j];}
cout<<endl;}
cout<<"\n\n Sehingga Didapatkan :\n";
cout<<" "<<L[1][1]<<"y1 = "<<B[1][1];
cout<<"\n "<<L[2][1]<<"y1 + "<<L[2][2]<<" y2 = "<<B[2][1];
cout<<"\n "<<L[3][1]<<"y1 + "<<L[3][2]<<" y2 + "<<L[3][3]<<" y3 = "<<B[3][1]<<endl;
y1=B[1][1]/L[1][1];
y2=(B[2][1]-(L[2][1]*y1))/L[2][2];
y3=(B[3][1]-(L[3][1]*y1+L[3][2]*y2))/L[3][3];
cout<<"\n hasil : "<<L[3][3];
x3=y3;
x2=(y2-(U[2][3]*x3));
x1=y1-((U[1][2]*x2)+(U[1][3]*x3));

cout<<"\n Jadi Didatakan Nilai-nilainya :\n";
cout<<"\n x1 : "<<x1;
cout<<"\n x2 : "<<x2;
cout<<"\n x3 : "<<x3;
cout<<"\n y1 : "<<y1;
cout<<"\n y2 : "<<y2;
cout<<"\n y3 : "<<y3<<endl;
/*-------Metode Gaus Jordan------*/
getch();main();
}


 Hasil Compile