NMDanny

S4

Jan 31st, 2013
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.09 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace S4
  7. {
  8.     class Program
  9.     {
  10.         static void Main(string[] args)
  11.         {
  12.  
  13.             Console.WriteLine("Type a string, it must end with an asterisk");
  14.             string St = Console.ReadLine();
  15.             if (St[St.Length - 1] != '*')
  16.             {
  17.                 Console.WriteLine("Invalid string! It didn't end with an asterisk");
  18.             }
  19.             else
  20.             {
  21.                 int[] Counter = new int[St.Length];
  22.                 for (int i = 0; i < St.Length; ++i)
  23.                 {
  24.                     if (St[i] >= 'a'&&St[i]<='z')
  25.                     {
  26.                         Counter[i] = 1;
  27.                     }
  28.                 }
  29.                 int az = 0;
  30.                 for (int i = 0; i < Counter.Length; ++i)
  31.                 {
  32.                     if (Counter[i] == 1)
  33.                     { ++az; }
  34.                 }
  35.                 Console.WriteLine("There are {0} small English letters in this string", az);
  36.             }
  37.         }
  38.     }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment