#include "iostream"
#include "math.h"
using namespace std;
class jarak{
friend istream& operator>>(istream&, jarak&);
friend ostream& operator<<(ostream&, jarak&); public: jarak(); float jarak_2titik(); private: float x1,x2,y1,y2,a,b,jrk; }; jarak::jarak(){ cout<<"menghitung jarak dua titik koordinat\n"<
cout<<"masukkan x1 : ";in>>mlebu.x1;
cout<<"masukkan y1 : ";in>>mlebu.y1;
cout<<"masukkan x2 : ";in>>mlebu.x2;
cout<<"masukkan y2 : ";in>>mlebu.y2;
return in;
}
ostream& operator<<(ostream& out, jarak& metu){ out<<"jarak kedua titik = "<
if(y1>y2) a = y1-y2;
if(x2>x1) b = x2-x1;
if(x1-x2) b = x1-x2;
jrk=sqrt((a*a)+(b*b));
}
int main(int argc, char *argv[])
{
jarak dyas;
cin>>dyas;
dyas.jarak_2titik();
cout<
system("PAUSE");
return EXIT_SUCCESS;
}




No comments:
Post a Comment