C++ Fungsi Jarak

#include<iostream>
#include<conio.h>
#include<math.h>

int x1,x2,y1,y2,jum;
float d;
void input(){
cout<<" masukan titik x1 : ";
cin>>x1;
cout<<" masukan titik y1 : ";
cin>>y1;
cout<<" p1("<<x1<<","<<y1<<")"<<endl;
cout<<endl;
cout<<" masukan titik x2 : ";
cin>>x2;
cout<<" masukan titik y2 : ";
cin>>y2;
cout<<" p2("<<x2<<","<<y2<<")"<<endl;
}

void jarak(){
jum=((x1-x2)*(x1-x2))+((y1-y2)*(y1-y2));
d=sqrt(jum);
cout<<d;;
}

main (){
input();
cout<<endl;
cout<<" jarak nya = ";
jarak();
getch();
}

0 Response to "C++ Fungsi Jarak"

Posting Komentar