/
215550
/
Konrol
Обзор
Документация
Войти
/
215550
/
Konrol
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
ControlWorks
Program.cs
150 строк
5 KB
215550
homew
15 ноя 2025, 12:44
15 ноя 2025, 12:44
9bd9779
Код
Авторство
О чём код?
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApp2 { internal class Program { static void Main(string[] args) { public class MinFinder { public static int FindMin(int[] nums){ if (nums == null || nums.Length == 0) { throw new ArgumentException("Массив не может быть пустым"); } int min = nums[0]; for (int i = 1; i < nums.Length; i++) { if (nums[i] < min) { min = nums[i]; } } return min;} } public class LowerCaseCounter { public static int CountLowerCase(string text) { if (string.IsNullOrEmpty(text)) { throw new ArgumentException("Строка не может быть пустой"); } int count = 0; foreach (char c in text) { if (Char.IsLower(c)) { count++; } } return count; } } public class ThirdFromEnd { public static char GetThirdFromEnd(string s) { if (string.IsNullOrEmpty(s) || s.Length < 3) { throw new ArgumentException("Строка должна содержать минимум 3 символа"); } return s[s.Length - 3]; } } public class PalindromeChecker { public static bool IsPalindrome(int x) { if (x < 0) { throw new ArgumentException("Число должно быть неотрицательным"); } if (x < 10) { return true; } int original = x; int reversed = 0; while (x > 0) { int lastDigit = x % 10; reversed = reversed * 10 + lastDigit; x = x / 10; } return original == reversed; } } public class RunningSumCalculator { public static int[] RunningSum(int[] nums) { if (nums == null || nums.Length == 0) { throw new ArgumentException("Массив не может быть пустым"); } int[] result = new int[nums.Length]; result[0] = 0; for (int i = 1; i < nums.Length; i++) { result[i] = result[i - 1] + nums[i - 1]; } return result; } } public class CustomTryParse { public static bool TryParse(string str, out int number) { number = 0; if (string.IsNullOrEmpty(str)) { throw new ArgumentException("Строка не может быть пустой или null"); } foreach (char c in str) { if (!Char.IsDigit(c)) { return false; } } try { number = int.Parse(str); return true; } catch { return false; } } } } }