/
Fleksey
/
Test_cr
Обзор
Документация
Войти
/
Fleksey
/
Test_cr
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
Program.cs
99 строк
2 KB
Flekseyy
Version 1.0
25 окт 2025, 16:09
25 окт 2025, 16:09
0c9f534
Код
Авторство
О чём код?
namespace Test_cr; class Program { static void Main(string[] args) { Console.WriteLine("Ответ #1" + " " + IsMin([3, 15, 1, 14])); Console.WriteLine("Ответ #2" + " " + IsCountStr("BananaRama")); Console.WriteLine("Ответ #3" + " " + IsLast3Simb("ABCDEFG")); Console.WriteLine("Ответ #4" + " " + IsPalindrome(121)); Console.WriteLine("Ответ #5"); int[] a = {0, 3, 14, 8, 2, 94} ; RunningSum(a); Console.WriteLine("Ответ №6" + " " + TryParse("1211412",out int number)); } // 1 static int IsMin(int[] mass) { int temp = 0; for(int i = 0; i < mass.Length; i++) { for(int j = i + 1; j < mass.Length; j++) { if (mass[i] > mass[j]) { temp = mass[j]; mass[i] = mass[j]; mass[j] = temp; } } } return mass[0]; } // 2 static int IsCountStr(string str) { int cnt = 0; for(int i = 0; i < str.Length;i++) { if(Char.IsLower(str[i])) { cnt+=1; } } return cnt; } // 3 static char IsLast3Simb(string s) { return s[s.Length - 3]; } // 4 static bool IsPalindrome(int x) { string s = x.ToString(); bool ist = true; int len = s.Length - 1; for(int i = 0; i <= len/ 2; i++) { if(s[i] != s[len - i]) { ist = false; break; } } return ist; } // 5 static int[] RunningSum(int[] nums) { int[] result = new int[nums.Length]; for(int i = 0; i < nums.Length; i++) { for(int j = 0; j < i; j++) { result[i] += nums[j]; } Console.WriteLine(result[i]); } return result; } //6 static bool TryParse(string str, out int number) { number = 0; bool ist = true; for(int i = 0; i < str.Length; i++) { if(Char.IsDigit(str[i]) == false) { ist = false; break; } } if(ist == true) number = int.Parse(str); return ist; } }