using System;
internal class Program {
private static void Main() {
var b = InputDouble("b: ");
var n = Math.Pow(Math.Pow(2.0 * b + 1.0, 3), 0.2) - 64.0 * b;
if (b < 0 || n < 0) {
Console.WriteLine("Недопустимый аргумент функции Math.Sqrt()");
} else {
var d = Math.Sqrt(5.0 * b) + 3.0 * Math.Sqrt(b) / 2.0;
if (b == 0 || d == 0) {
Console.WriteLine("Попытка деления на ноль");
} else {
var z = Math.Sqrt
/ d;
Console.WriteLine($"z: {z}");
}
}
Console.ReadKey();
}
private static double InputDouble(string message) {
while (true) {
Console.Write(message);
if (double.TryParse(Console.ReadLine(), out double value)) {
return value;
}
}
}
} using System;
using System.Globalization;
internal class Program {
private static void Main() {
var distance = InputDouble("Введите длину отрезка в метрах: ");
var vershok = distance / MetricUnits.VERSHOK;
var arshin = distance / MetricUnits.ARSHIN;
var fathom = distance / MetricUnits.FATHOM;
var verst = distance / MetricUnits.VERST;
var fmtVershok = string.Format(CultureInfo.InvariantCulture, "{0:0.0}", vershok);
var fmtArshin = string.Format(CultureInfo.InvariantCulture, "{0:0.00}", arshin);
var fmtFathom= string.Format(CultureInfo.InvariantCulture, "{0:0.000}", fathom);
var fmtVerst = string.Format(CultureInfo.InvariantCulture, "{0:0.0000}", verst);
Console.WriteLine("Вершков: " + fmtVershok);
Console.WriteLine("Аршинов: " + fmtArshin);
Console.WriteLine("Саженей: " + fmtFathom);
Console.WriteLine("Вёрст: " + fmtVerst);
Console.ReadKey();
}
private readonly struct MetricUnits {
public static readonly double VERSHOK = 0.04445;
public static readonly double ARSHIN = 16.0 * VERSHOK;
public static readonly double FATHOM = 3.0 * ARSHIN;
public static readonly double VERST = 500.0 * FATHOM;
}
private static double InputDouble(string message) {
while (true) {
Console.Write(message);
if (double.TryParse(Console.ReadLine(), out double value)) {
return value;
}
}
}
}