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


using System;

class Task1
{
    static void Main()
    {
        Console.Write("Введите символ: ");
        char symbol = Console.ReadKey().KeyChar;
        Console.WriteLine();
        
        if (char.IsDigit(symbol))
            Console.WriteLine($"Символ '{symbol}' является цифрой.");
        else
            Console.WriteLine($"Символ '{symbol}' не является цифрой.");
    }
}
using System;

class Task2
{
    static void Main()
    {
        Console.Write("Введите текст: ");
        string text = Console.ReadLine();
        
        Console.Write("Цифры в тексте: ");
        foreach (char c in text)
        {
            if (char.IsDigit(c))
                Console.Write(c + " ");
        }
    }
}

using System;

class Task3
{
    static void Main()
    {
        Console.Write("Введите текст: ");
        string text = Console.ReadLine();
        
        int count = 0;
        foreach (char c in text)
        {
            if (char.IsDigit(c))
                count++;
        }
        
        Console.WriteLine($"Количество цифр: {count}");
    }
}

using System;

class Task4
{
    static void Main()
    {
        Console.Write("Введите текст: ");
        string text = Console.ReadLine();
        
        int sum = 0;
        int maxDigit = -1;
        
        foreach (char c in text)
        {
            if (char.IsDigit(c))
            {
                int digit = c - '0';
                sum += digit;
                if (digit > maxDigit)
                    maxDigit = digit;
            }
        }
        
        Console.WriteLine($"Сумма цифр: {sum}");
        Console.WriteLine($"Максимальная цифра: {maxDigit}");
    }
}

using System;

class Task5
{
    static void Main()
    {
        Console.Write("Введите текст: ");
        string text = Console.ReadLine();
        
        // Находим первый не пробельный символ
        int startIndex = 0;
        while (startIndex < text.Length && text[startIndex] == ' ')
            startIndex++;
        
        int maxDigit = -1;
        int position = -1;
        
        for (int i = startIndex; i < text.Length; i++)
        {
            if (char.IsDigit(text[i]))
            {
                int digit = text[i] - '0';
                if (digit > maxDigit)
                {
                    maxDigit = digit;
                    position = i - startIndex + 1;
                }
            }
        }
        
        Console.WriteLine($"Максимальная цифра: {maxDigit}");
        Console.WriteLine($"Позиция: {position}");
    }
}