Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace ConsoleApplication221018
- {
- class Program
- {
- static void Main(string[] args)
- {
- Console.WriteLine("Выберите задание");
- int choose = Convert.ToInt32(Console.ReadLine());
- if (choose == 1)
- {
- Console.WriteLine("Введите число");
- int num = Convert.ToInt32(Console.ReadLine());
- int[] num2 = num.ToString().Select(digit => int.Parse(digit.ToString())).ToArray();
- Array.Sort(num2);
- Array.Reverse(num2);
- Console.WriteLine("Наибольшая цифра числа: {0}", num2[0]);
- Console.ReadKey();
- }
- if (choose == 2)
- {
- Console.WriteLine("Введите число");
- int num = Convert.ToInt32(Console.ReadLine());
- int[] num2 = num.ToString().Select(digit => int.Parse(digit.ToString())).ToArray();
- int chet = 0;
- int nechet = 0;
- int i = 0;
- while (num2.Length != chet + nechet)
- {
- if (num2[i] % 2 == 0)
- {
- chet++;
- }
- else
- {
- nechet++;
- }
- i++;
- }
- Console.WriteLine("Чётные: {0} Нечётные: {1}", chet, nechet);
- Console.ReadKey();
- }
- if (choose == 3)
- {
- Console.WriteLine("Введите число");
- int num = Convert.ToInt32(Console.ReadLine());
- int[] num2 = num.ToString().Select(digit => int.Parse(digit.ToString())).ToArray();
- int num2Final = 0;
- Array.Reverse(num2);
- for (int i = 0; i < num2.Length; i++)
- {
- num2Final += num2[i] * Convert.ToInt32(Math.Pow(10, num2.Length - i - 1));
- }
- Console.WriteLine("Перевёрнутое число: {0}", num2Final);
- Console.ReadKey();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement