Anonim_999

zad

Nov 15th, 2022
814
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. namespace Zad
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             Console.WriteLine($"Результат: {FindSymboleOnce(Console.ReadLine(), 'b')}");
  10.         }
  11.  
  12.         private static bool FindSymboleOnce(string text, char needSymbol)
  13.         {
  14.             int countFound = 0;
  15.  
  16.             foreach (char sybmol in text)
  17.             {
  18.                 if (sybmol == needSymbol)
  19.                     countFound++;
  20.  
  21.                 if (countFound > 1)
  22.                     return false;
  23.             }
  24.  
  25.             if (countFound == 0)
  26.                 return false;
  27.             else
  28.                 return true;
  29.         }
  30.     }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment