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 ConsoleApplication1
- {
- class Program
- {
- static void Main(string[] args)
- {
- string tmp;
- Console.WriteLine("Введите строку :");
- string text = Console.ReadLine();
- Console.WriteLine("Количество слов в строке :");
- string[] words = text.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
- Console.WriteLine(words.Length);
- Console.WriteLine("Слова с чётным количеством букв:");
- foreach (string word in words)
- {
- if (word.Length % 2 == 0)
- {
- Console.WriteLine(word);
- }
- }
- Console.WriteLine("Строка в обратном порядке:");
- for (int i = 0; i < words.Length; i++)
- {
- if (words[i] == words[words.Length - i - 1])
- {
- break;
- }
- tmp = words[i];
- words[i] = words[words.Length - i - 1];
- words[words.Length - i - 1] = tmp;
- }
- foreach (string word in words)
- {
- Console.Write(word + " ");
- }
- Console.ReadKey();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement