bacco

Сумиране на гласни букви : Loop; Switch

Jan 29th, 2018
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.67 KB | None | 0 0
  1. using System;
  2.  
  3. namespace tESt
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.  
  10.             var text = Console.ReadLine();
  11.  
  12.             var sum = 0;
  13.  
  14.             for (int i = 0; i < text.Length; i++)
  15.             {
  16.                 char curent = text[i];
  17.  
  18.                 switch (curent)
  19.                 {
  20.                     case 'a': sum += 1; break;
  21.                     case 'e': sum += 2; break;
  22.                     case 'i': sum += 3; break;
  23.                     case 'o': sum += 4; break;
  24.                     case 'u': sum += 5; break;
  25.                 }
  26.             }
  27.  
  28.             Console.WriteLine(sum);
  29.         }
  30.     }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment