[C++] Viết chương trình nhập vào tọa độ 2 điểm A và B. Xuất ra khoảng cách AB
06:01
Đề: Viết chương trình nhập vào tọa độ 2 điểm A và B. Xuất ra khoảng cách AB
#include<iostream>
#include<math.h>
using namespace std;
struct Coordinates{
int abscissae;
int absolute;
};
main(){
Coordinates PointA,PointB;
cout<<"Enter the coodinates of point A:\n";
cout<<"Abscissae:";
cin>>PointA.abscissae;
cout<<"Absolute:";
cin>>PointA.absolute;
system("cls");
cout<<"Enter the coodinates of point B:\n";
cout<<"Abscissae";
cin>>PointB.abscissae;
cout<<"Absolute";
cin>>PointB.absolute;
system("cls");
float a,b,Distance;
cout<<"DISTANCE FROM POINT A TO POINT B IS: ";
a=PointA.abscissae-PointB.abscissae;
b=PointB.absolute-PointA.absolute;
Distance= sqrt(pow(a,2)+pow(b,2));
cout<<Distance<<endl;
}
#include<iostream>
#include<math.h>
using namespace std;
struct Coordinates{
int abscissae;
int absolute;
};
main(){
Coordinates PointA,PointB;
cout<<"Enter the coodinates of point A:\n";
cout<<"Abscissae:";
cin>>PointA.abscissae;
cout<<"Absolute:";
cin>>PointA.absolute;
system("cls");
cout<<"Enter the coodinates of point B:\n";
cout<<"Abscissae";
cin>>PointB.abscissae;
cout<<"Absolute";
cin>>PointB.absolute;
system("cls");
float a,b,Distance;
cout<<"DISTANCE FROM POINT A TO POINT B IS: ";
a=PointA.abscissae-PointB.abscissae;
b=PointB.absolute-PointA.absolute;
Distance= sqrt(pow(a,2)+pow(b,2));
cout<<Distance<<endl;
}