TOPIC
BEE 1015 - Distance Between Two Points
gabsuchoa asked 1 year ago
Hi, I'm trying to make this code run as the multiple var input in the exercise says... but I'm having problems that I can't find/figure out how to do it. The program works fine with one line one read on the console.
using System;
class URI {
static void Main(string[] args) {
double x1, x2, y1, y2;
string line = Console.ReadLine();
string[] x = line.Split(' ');
x1 = Convert.ToDouble(x[0]);
y1 = Convert.ToDouble(x[1]);
x2 = Convert.ToDouble(x[2]);
y2 = Convert.ToDouble(x[3]);
//x1 = Convert.ToDouble(Console.ReadLine());
//y1 = Convert.ToDouble(Console.ReadLine());
//x2 = Convert.ToDouble(Console.ReadLine());
//y2 = Convert.ToDouble(Console.ReadLine());
double d = Math.Sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));
double dr = Math.Round((Double) d, 4);
Console.WriteLine(dr);
}
}
This topic has not been answered yet. Be the first!