面试题答案
一键面试use std::cmp::sqrt;
struct Point {
x: i32,
y: i32,
}
impl Point {
fn new(x: i32, y: i32) -> Self {
Self { x, y }
}
fn distance(&self) -> f64 {
sqrt((self.x * self.x + self.y * self.y) as f64)
}
}
use std::cmp::sqrt;
struct Point {
x: i32,
y: i32,
}
impl Point {
fn new(x: i32, y: i32) -> Self {
Self { x, y }
}
fn distance(&self) -> f64 {
sqrt((self.x * self.x + self.y * self.y) as f64)
}
}