Advertisement
ElliasBLR

Женя

Oct 28th, 2020
1,828
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.46 KB | None | 0 0
  1. using System;
  2. class HelloWorld
  3. {
  4.     static void Main()
  5.     {
  6.      
  7.  
  8.  
  9.  
  10.         int p = 0;
  11.         int index = 0;
  12.         int n = 0;
  13.         string tmp;
  14.         Console.WriteLine("Введите строку :");
  15.         string text = Console.ReadLine();
  16.         Console.WriteLine("Количество слов в строке  :");
  17.         string[] words = text.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  18.         Console.WriteLine(words.Length);
  19.        
  20.         //
  21.         Console.WriteLine("Введите значение длинны");
  22.         int avg = Convert.ToInt16(Console.ReadLine());
  23.  
  24.         Console.WriteLine("Слова, длинна которых превышает значение:");
  25.              
  26.         foreach (string word in words)
  27.         {
  28.             if (word.Length > avg)
  29.             {
  30.                 Console.WriteLine(word);
  31.             }
  32.         }
  33.  
  34.         Console.WriteLine("Введите сочетание");
  35.         string W = Console.ReadLine();
  36.         Console.WriteLine("Сколько раз введённое сочетание встречается в каждом слове : ");
  37.         foreach(string word in words)
  38.         {
  39.             while ((index = word.IndexOf(W, index) + 1) != 0) n++;
  40.            
  41.         }
  42.         Console.WriteLine(n);
  43.     // while ((index = a.IndexOf(b, index) + 1) != 0) count++;
  44.     // Console.WriteLine(count);
  45.  
  46.         Console.ReadKey();
  47.  
  48.     }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement