87 lines
3.0 KiB
C#
87 lines
3.0 KiB
C#
using System;
|
||
|
||
public class Program
|
||
{
|
||
static void Main(string[] args)
|
||
{
|
||
int x, y;
|
||
|
||
Console.WriteLine("Введите первое число: ");
|
||
x = int.Parse(Console.ReadLine());
|
||
Console.WriteLine("Введите второе число: ");
|
||
y = int.Parse(Console.ReadLine());
|
||
|
||
int greater = Utils.Greater(x, y);
|
||
|
||
Console.WriteLine("Большим из чисел {0} и {1} является {2} ", x, y, greater);
|
||
|
||
Console.WriteLine("До swap: \t" + x + " " + y);
|
||
Utils.Swap(ref x, ref y);
|
||
Console.WriteLine("После swap: \t" + x + " " + y);
|
||
|
||
int f;
|
||
bool ok;
|
||
|
||
Console.WriteLine("Number for factorial:");
|
||
x = int.Parse(Console.ReadLine());
|
||
|
||
ok = Utils.Factorial(x, out f);
|
||
|
||
if (ok)
|
||
Console.WriteLine("Factorial(" + x + ") = " + f);
|
||
else
|
||
Console.WriteLine("Cannot compute this factorial");
|
||
|
||
Console.WriteLine("choose the type of the triangle. type 1 for equilateral else 2: ");
|
||
int triangleType = int.Parse(Console.ReadLine());
|
||
|
||
switch (triangleType)
|
||
{
|
||
|
||
|
||
case 1:
|
||
Console.WriteLine("input side length: ");
|
||
double a = double.Parse(Console.ReadLine());
|
||
Console.WriteLine("area = {0}", Operation.TriangleArea(a));
|
||
break;
|
||
case 2:
|
||
Console.WriteLine("input first side length: ");
|
||
double sideA = double.Parse(Console.ReadLine());
|
||
Console.WriteLine("input second side length: ");
|
||
double sideB = double.Parse(Console.ReadLine());
|
||
Console.WriteLine("input third side length: ");
|
||
double sideC = double.Parse(Console.ReadLine());
|
||
Console.WriteLine("area = {0}", Operation.TriangleArea(sideA, sideB, sideC));
|
||
break;
|
||
default:
|
||
Console.WriteLine("invalid triangle type");
|
||
break;
|
||
}
|
||
|
||
|
||
Console.WriteLine("input coefficient a: ");
|
||
int coef_a = int.Parse(Console.ReadLine());
|
||
Console.WriteLine("input coefficient b: ");
|
||
int coef_b = int.Parse(Console.ReadLine());
|
||
Console.WriteLine("input coefficient c: ");
|
||
int coef_c = int.Parse(Console.ReadLine());
|
||
|
||
double x1, x2;
|
||
int res = Operation.SolveQuadratic(coef_a, coef_b, coef_c, out x1, out x2);
|
||
|
||
if (res == 1)
|
||
{
|
||
Console.WriteLine("Корни уравнения с коэффициентами a = {0}, b = {1}, c = {2} равны x1 = {3}, x2 = {4}.", coef_a, coef_b, coef_c, x1, x2);
|
||
}
|
||
else if (res == 0)
|
||
{
|
||
Console.WriteLine("Корень уравнения с коэффициентами a = {0}, b = {1}, c = {2} равны один x1 = x2 = {0}", coef_a, coef_b, coef_c, x1);
|
||
}
|
||
else
|
||
{
|
||
Console.WriteLine("Корней уравнения с коэффициентами a = {0}, b = {1}, c = {2} нет.", coef_a, coef_b, coef_c);
|
||
}
|
||
|
||
}
|
||
}
|