Advertisement
_CodeBehind

.Count_of_Capital_Letters_in_Array

Feb 11th, 2017
220
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.80 KB | None | 0 0
  1. namespace _1._7.Count_of_Capital_Letters_in_Array
  2. {
  3.     using System;
  4.     using System.Linq;
  5.  
  6.     public class Capital_Letters_in_Array
  7.     {
  8.         public static void Main()
  9.         {
  10.             string[] words = Console.ReadLine().Split(' ').ToArray();
  11.  
  12.             char[] lettersLeft = new char[words.Length];
  13.  
  14.             int counter = 0;
  15.  
  16.             for (int i = 0; i < words.Length; i++)
  17.             {
  18.                 if (words[i].Length == 1)
  19.                 {
  20.                     lettersLeft[i] = char.Parse(words[i]);
  21.                 }
  22.             }
  23.  
  24.             foreach (var letter in lettersLeft)
  25.             {
  26.                 if (letter!=0)
  27.                 {
  28.                     counter++;
  29.                 }
  30.             }
  31.             Console.WriteLine(counter);
  32.         }
  33.     }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement