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 korobka = Console.ReadLine();
- Console.WriteLine("Количество слов в строке :");
- string[] korobka2 = korobka.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
- Console.WriteLine(korobka2.Length);
- Console.WriteLine("Все слова, которые стоят на чётных позициях:");
- for (int i = 0; i < korobka2.Length; i++)
- {
- if (i % 2 == 1)
- {
- Console.WriteLine(korobka2[i]);
- }
- }
- Console.WriteLine("Перевёрнутая строка:");
- for (int i = 0; i < korobka2.Length; i++)
- {
- if (korobka2[i] == korobka2[korobka2.Length-i-1])
- {
- break;
- }
- tmp = korobka2[i];
- korobka2[i] = korobka2[korobka2.Length - i-1];
- korobka2[korobka2.Length - i - 1] = tmp;
- }
- foreach(string word in korobka2)
- {
- Console.Write(word + " ");
- }
- Console.ReadKey();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement