-Membuat algoritma dan program untuk mencari titik tengah sebuah garis yang ujung titiknya adalah A(x1,y1) dan B(x2,y2).
#include <iostream.h>
void titik_tengah (float x1, float y1, float x2, float y2, float hasil, float hasilx, float hasily){
hasil = x1 + x2;
hasilx = hasil / 2;
hasil = 0;
hasil = y1 + y2;
hasily = hasil / 2;
cout<<"\n\nKoordinat Titik Tengah T adalah : x=" << hasilx << ", y=" << hasily;
cout<<" => T(x, y) === T(" << hasilx << ", " << hasily << ")";
}
int main(){
float x1, y1, x2, y2;
float hasil, hasilx, hasily;
cout<<"Menghitung Titik Tengah\n\n";
cout<<"A.....T.....B\n\n";
cout<<"Masukkan Koordinat titik A\n";
cout<<"Ax : ";
cin>>x1;
cout<<"Ay : ";
cin>>y1;
cout<<"\nMasukkan Koordinat titik B\n";
cout<<"Bx : ";
cin>>x2;
cout<<"By : ";
cin>>y2;
titik_tengah(x1,y1,x2,y2,hasil,hasilx, hasily);
cin>>x1;
return 0;
}
-program untuk menghitung determinan matriks berordo 2x2
berikut source codenya :
#include <iostream.h>berikut source codenya :
class ORDO {
private:
int a, b, c, d;
float hasil;
public:
void Set_Input(){
cout<<"menghitung menghitung determinan matriks berordo 2x2"<<endl;
cout<<"|"<<"a"<<" "<<"b"<<"|"<<endl;
cout<<"|"<<"c"<<" "<<"d"<<"|"<<endl;
cout<<"masukkan bilangan a :";
cin>>a;
cout<<"masukkan bilangan b :";
cin>>b;
cout<<"masukkan bilangan c :";
cin>>c;
cout<<"masukkan bilangan d :";
cin>>d;
cout<<"\n";
}
void Set_Proses(){
hasil = (a*d)-(b*c);
}
void Set_Output(){
cout<<"hasil ordo adalah :"<<hasil<<endl;
cout<<"|"<<a<<" "<<b<<"|"<<endl;
cout<<"|"<<c<<" "<<d<<"|"<<endl;
}
};
int main(){
int x;
ORDO O;
O.Set_Input();
O.Set_Proses();
O.Set_Output();
cin>>x;
return 0;
}
Tidak ada komentar:
Posting Komentar