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


using System;

class Program
{
    static void Main()
    {
        Console.Write("Введите ε: ");
        double eps = double.Parse(Console.ReadLine());

        double a_prev = 1;
        double a_curr = 0;
        int n = 1;

        Console.WriteLine($"a_{n} = {a_prev}");

        while (true)
        {
            n++;
            a_curr = 0.5 * (a_prev + 2.0 / a_prev);
            Console.WriteLine($"a_{n} = {a_curr}");

            if (Math.Abs(a_curr * a_curr - 2) < eps)
                break;

            a_prev = a_curr;
        }

        Console.WriteLine($"\nНаименьший номер: {n}");
        Console.ReadKey();
    }
}
using System;

class Program
{
    static void Main()
    {
        Console.Write("Введите a: ");
        double a = double.Parse(Console.ReadLine());

        Console.Write("Введите b: ");
        double b = double.Parse(Console.ReadLine());

        Console.Write("Введите h: ");
        double h = double.Parse(Console.ReadLine());

        Console.WriteLine("x\tF(x)");

        for (double x = a; x <= b + 1e-9; x += h)
        {
            double fx = -Math.Cos(2 * x);
            Console.WriteLine($"{x}\t{fx}");
        }

        Console.ReadKey();
    }
}
using System;

class Program
{
    static void Main()
    {
        Console.Write("Введите N: ");
        int N = int.Parse(Console.ReadLine());

        int temp = N;
        int countDigits = 0;

        // Подсчёт количества цифр
        while (temp > 0)
        {
            countDigits++;
            temp /= 10;
        }

        int half = countDigits / 2;
        temp = N;
        int sum = 0;

        // Отбрасываем старшие разряды
        for (int i = 0; i < half; i++)
        {
            sum += temp % 10;
            temp /= 10;
        }

        Console.WriteLine($"Сумма цифр во второй половине числа: {sum}");
        Console.ReadKey();
    }
}
using System;

class Program
{
    static void Main()
    {
        // Перебираем возможный номер дома Петра
        for (int petr = 1; petr < 100; petr++)
        {
            int sum1 = 0;
            int current = petr;

            // Первый квартал — сумма 99
            while (sum1 < 99)
            {
                sum1 += current;
                current++;
            }

            if (sum1 != 99) continue;

            // Второй квартал — сумма 117
            int sum2 = 0;
            while (sum2 < 117)
            {
                sum2 += current;
                current++;
            }

            if (sum2 != 117) continue;

            // Третий квартал — сумма 235 (включая номер школы)
            int sum3 = 0;
            int school = 0;
            while (sum3 < 235)
            {
                sum3 += current;
                if (sum3 == 235)
                    school = current;
                current++;
            }

            if (sum3 == 235)
            {
                Console.WriteLine($"Номер дома Петра: {petr}");
                Console.WriteLine($"Номер школы: {school}");
                Console.ReadKey();
                return;
            }
        }

        Console.WriteLine("Решение не найдено");
        Console.ReadKey();
    }
}
using System;
using System.Collections.Generic;

class Program
{
    static List<int> partition = new List<int>();
    static int count = 0;

    static void Main()
    {
        Console.Write("Введите n: ");
        int n = int.Parse(Console.ReadLine());

        Console.WriteLine("Разбиения числа " + n + ":");
        GeneratePartitions(n, n);

        Console.WriteLine($"\nP({n}) = {count}");
        Console.ReadKey();
    }

    static void GeneratePartitions(int remaining, int maxPart)
    {
        if (remaining == 0)
        {
            // Вывод разбиения
            for (int i = 0; i < partition.Count; i++)
            {
                Console.Write(partition[i]);
                if (i < partition.Count - 1) Console.Write(" + ");
            }
            Console.WriteLine();
            count++;
            return;
        }

        for (int part = Math.Min(maxPart, remaining); part >= 1; part--)
        {
            partition.Add(part);
            GeneratePartitions(remaining - part, part);
            partition.RemoveAt(partition.Count - 1);
        }
    }
}