Advertisement
hnyrenhjm5678

Untitled

Feb 14th, 2025
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.69 KB | None | 0 0
  1. using System;
  2.  
  3. class Program
  4. {
  5.     static void Main()
  6.     {
  7.         Console.WriteLine("Въведи текст:");
  8.         string text = Console.ReadLine();
  9.  
  10.         if (text.Length < 50)
  11.         {
  12.             Console.WriteLine("Текстът е твърде кратък!");
  13.             return;
  14.         }
  15.  
  16.         int[] count = new int[256];
  17.  
  18.         foreach (char c in text)
  19.         {
  20.             if (c < 256)
  21.             {
  22.                 count[c]++;
  23.             }
  24.         }
  25.  
  26.         for (int i = 0; i < count.Length; i++)
  27.         {
  28.             if (count[i] > 0)
  29.             {
  30.                 Console.WriteLine((char)i + " - " + count[i]);
  31.             }
  32.         }
  33.     }
  34. }
  35.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement