Advertisement
Aborigenius

CountSingleUpperCase

Jun 16th, 2017
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.14 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace CountUppercaseLetters
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             string N = Console.ReadLine();
  14.             string[] MyArray = N.Split(' ').ToArray();
  15.             int count = 0;
  16.             //        for (int i = 0; i < MyArray.Length - 1; i++)
  17.             //        {
  18.             //            //  MyArray[i].Where(c => c >= 'A' && c <= 'Z').Count();
  19.             //        }
  20.  
  21.             //     count = N.Count(char.IsUpper);
  22.  
  23.             char[] capitalLetters = new char[MyArray.Length];
  24.  
  25.             for (int i = 0; i < MyArray.Length; i++)
  26.             {
  27.                 if (MyArray[i].Length == 1)
  28.                 {
  29.                     capitalLetters[i] = char.Parse(MyArray[i]);
  30.                 }
  31.             }
  32.  
  33.             foreach (var letter in capitalLetters)
  34.             {
  35.                 if (letter != 0)
  36.                 {
  37.                     count++;
  38.                 }
  39.             }
  40.  
  41.             Console.WriteLine(count);
  42.  
  43.         }
  44.     }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement