Create a gist now

Instantly share code, notes, and snippets.

#include <cmath>
#include <iostream>
struct Coordinate {
double x;
double y;
double Distance();
};
double Coordinate::Distance(){
double t = this->x * this->x + this->y * this->y;
return std::sqrt( t );
}
int main(){
Coordinate p;//点P
p.x = 3.0f;
p.y = 4.0f;
std::cout << p.Distance() << std::endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment