Advertisement
Martichka

Array/ Task 12 - Alphabet

Jan 13th, 2013
39
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.65 KB | None | 0 0
  1. using System;
  2. class Alphabet
  3. {
  4.     static void Main()
  5.     {
  6.         int[] alpha = new int[26];
  7.         for (int index = 0; index < alpha.Length; index++)
  8.         {
  9.             alpha[index] = 'a' + index;
  10.         }
  11.         Console.Write("Write a word: ");
  12.         string word = Console.ReadLine();
  13.         for (int letters = 0; letters < word.Length; letters++)
  14.         {
  15.             for (int index = 0; index < alpha.Length; index++)
  16.             {
  17.                 if (word[letters]==alpha[index])
  18.                 {
  19.                     Console.Write(index+ " ");
  20.                     break;
  21.                 }
  22.             }
  23.         }
  24.     }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement