bacco

Сумиране на гласни букви ; for loops

Jan 29th, 2018
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.94 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.                 if (curent == 'a')
  19.                 {
  20.                     sum += 1;
  21.                 }
  22.                  if (curent == 'e')
  23.                 {
  24.                     sum += 2;
  25.                 }
  26.                  if (curent == 'i')
  27.                 {
  28.                     sum += 3;
  29.                 }
  30.                  if (curent == 'o')
  31.                 {
  32.                     sum += 4;
  33.                 }
  34.                  if (curent == 'u')
  35.                 {
  36.                     sum += 5;
  37.                 }
  38.             }
  39.  
  40.             Console.WriteLine(sum);
  41.         }
  42.     }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment