Advertisement
AmirVagapov

Find ch

Apr 2nd, 2023
691
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.45 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3.  
  4. class Program {
  5.  public static int Main() {
  6.      
  7.   Console.Write("Введите строку  : ");
  8.   string S = Console.ReadLine();
  9.   char ch = 'c';
  10.   // int count = S.Where(a => a.ToString() == ch).ToList().Count();
  11.     //Console.WriteLine(count);
  12.     int res = 0;
  13.     for(int i = 0; i < S.Length; i++) {
  14.         if(S[i] == ch) res++;
  15.     }
  16.     Console.WriteLine(res);
  17.   Console.ReadKey();
  18.   return 0;
  19.  }
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement