Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Напишете програма която приема като вход от потребителя текстов ред съдържащ думи разделени с интервал.
- Нека програмата отпечата всички думи от въведения текст които започват с главна буква.
- (Hint: използвайте методите Split на класа String и IsUpper на Char)
- Примeр:
- Вход: The wolf of Wall Street
- Изход: The Wall Street */
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace _02_UpperLetter
- {
- class UpperLetter
- {
- static void Main()
- {
- Console.WriteLine("Write some text:");
- Console.WriteLine();
- string line = Console.ReadLine();
- string [] words = line.Split(' ');
- Console.WriteLine();
- Console.WriteLine("UpperLetters in text are: ");
- Console.WriteLine();
- foreach (var word in words)
- {
- if(char.IsUpper(word[0])) // string се държи като масив. Елементите на string са чарове (char) можем да достъпим свсеки един char чрез индекс.
- Console.Write(word + " ");
- }
- Console.ReadLine();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment