Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace Problem_02
- {
- using System;
- public class StartUp
- {
- public static void Main()
- {
- //Прочитаме входа
- string input = Console.ReadLine();
- //Извикваме функцията за броене на думите в текста
- WordsCount(input);
- //Извикваме функцията за смяна на главните с малки букви
- ToLower(input);
- //Извикваме функцията за броене на числата в текста
- DigitCount(input);
- }
- //Функция за броене на думите
- public static void WordsCount(String input)
- {
- string[] words = input.Split(new char[] { ' ', ',', '.' }, StringSplitOptions.RemoveEmptyEntries);
- int wordCount = words.Length;
- Console.WriteLine("Броят на думите в текста са: " + wordCount);
- }
- //Функция за броене на цифрите
- public static void DigitCount(String input)
- {
- int zero = 0;
- int one = 0;
- int two = 0;
- int three = 0;
- int four = 0;
- int five = 0;
- int six = 0;
- int seven = 0;
- int eight = 0;
- int nine = 0;
- //За всеки символ от текста проверяваме дали е цифра
- //за всяко съвпадение увеличаваме броя на конкретната цифра
- foreach (var character in input)
- {
- switch (character)
- {
- case '0':
- zero++;
- break;
- case '1':
- one++;
- break;
- case '2':
- two++;
- break;
- case '3':
- three++;
- break;
- case '4':
- four++;
- break;
- case '5':
- five++;
- break;
- case '6':
- six++;
- break;
- case '7':
- seven++;
- break;
- case '8':
- eight++;
- break;
- case '9':
- nine++;
- break;
- default:
- break;
- }
- }
- Console.WriteLine("Числата които се срещат в текста са:");
- Console.WriteLine("Нула: " + zero);
- Console.WriteLine("Едно: " + one);
- Console.WriteLine("Две: " + two);
- Console.WriteLine("Три: " + three);
- Console.WriteLine("Четири: " + four);
- Console.WriteLine("Пет: " + five);
- Console.WriteLine("Шест: " + six);
- Console.WriteLine("Седем: " + seven);
- Console.WriteLine("Осем: " + eight);
- Console.WriteLine("Девет: " + nine);
- }
- //Функция за смяна на главните с малки букви
- public static void ToLower(String input)
- {
- string output = input.ToLower();
- Console.WriteLine(output);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement