Загрузка данных


// 1 задание
Console.WriteLine("1 задание");
Console.WriteLine("It's easy to win forgiveness for being wrong;");
Console.WriteLine("being right is what gets you into real trouble.");
Console.WriteLine("Bjarne Stroustrup");
Console.WriteLine("\n");
// 2 задание
Console.WriteLine("2 задание");
Console.WriteLine("Введите 5 чисел:");

Console.Write("Число 1: ");
double n1 = Convert.ToDouble(Console.ReadLine());
Console.Write("Число 2: ");
double n2 = Convert.ToDouble(Console.ReadLine());
Console.Write("Число 3: ");
double n3 = Convert.ToDouble(Console.ReadLine());
Console.Write("Число 4: ");
double n4 = Convert.ToDouble(Console.ReadLine());
Console.Write("Число 5: ");
double n5 = Convert.ToDouble(Console.ReadLine());

double sum = n1 + n2 + n3 + n4 + n5;
double product = n1 * n2 * n3 * n4 * n5;

double min = n1;
if (n2 < min) min = n2;
if (n3 < min) min = n3;
if (n4 < min) min = n4;
if (n5 < min) min = n5;

double max = n1;
if (n2 > max) max = n2;
if (n3 > max) max = n3;
if (n4 > max) max = n4;
if (n5 > max) max = n5;

Console.WriteLine();
Console.WriteLine("Сумма чисел: " + sum);
Console.WriteLine("Максимум: " + max);
Console.WriteLine("Минимум: " + min);
Console.WriteLine("Произведение чисел: " + product);
Console.WriteLine("\n");
// 3 задание
Console.WriteLine("3 задание");
Console.Write("Введите шестизначное число: ");
int number = Convert.ToInt32(Console.ReadLine());

int d1 = number % 10;
int d2 = (number / 10) % 10;
int d3 = (number / 100) % 10;
int d4 = (number / 1000) % 10;
int d5 = (number / 10000) % 10;
int d6 = number / 100000;

int reversed = d1 * 100000 + d2 * 10000 + d3 * 1000 + d4 * 100 + d5 * 10 + d6;

Console.WriteLine("Результат: " + reversed);
Console.WriteLine("\n");
// 4 задание
Console.WriteLine("4 задание");

Console.Write("Введите начало диапазона: ");
int minin = Convert.ToInt32(Console.ReadLine());
Console.Write("Введите конец диапазона: ");
int maxim = Convert.ToInt32(Console.ReadLine());
Console.WriteLine();
Console.WriteLine("Числа Фибоначчи в диапазоне:");
int a = 0;
int b = 1;
if (a >= minin)
{
    if (a <= maxim)
    {
        Console.Write(a + " ");
    }
}
while (b <= maxim)
{
    if (b >= minin)
    {
        Console.Write(b + " ");
    }
    int next = a + b;
    a = b;
    b = next;
}
Console.WriteLine();
// 5 задание
Console.WriteLine("5 задание");
Console.Write("Введите число A: ");
int aa = Convert.ToInt32(Console.ReadLine());

Console.Write("Введите число B: ");
int bb = Convert.ToInt32(Console.ReadLine());

Console.WriteLine();
Console.WriteLine("Результат:");

for (int i = aa; i <= bb; i = i + 1)
{
    for (int j = 0; j < i; j = j + 1)
    {
        Console.Write(i);
    }
    Console.WriteLine(); 
}
Console.WriteLine();
// 6 задание
Console.WriteLine("6 задание");
Console.Write("Введите длину линии: ");
int length = Convert.ToInt32(Console.ReadLine());

Console.Write("Введите символ заполнитель: ");
string symbol = Console.ReadLine(); 

Console.Write("Введите направление (horizontal или vertical): ");
string direction = Console.ReadLine();

Console.WriteLine();
Console.WriteLine("Результат:");

for (int i = 0; i < length; i = i + 1)
{
    if (direction == "horizontal")
    {
        Console.Write(symbol); // 
    }
    if (direction == "vertical")
    {
        Console.WriteLine(symbol); 
}
Console.WriteLine();