Created
February 27, 2014 09:17
-
-
Save d8ta/9246869 to your computer and use it in GitHub Desktop.
Aufgabe 2: RLE
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| class MainClass | |
| { | |
| const int CODE_OF_A = 65; // ASCII code for A | |
| const int CODE_OF_a = 97; // ASCII code for a | |
| static int[] uppercase = new int[26]; | |
| static int[] lowercase = new int[26]; // Arrays for upper and lowercase alphabet | |
| static void Userinput () | |
| { | |
| string stringinput = Console.ReadLine (); | |
| for (int i = 0; i < stringinput.Length; i++) | |
| { | |
| for (int j = 0; j < uppercase.Length; j++) | |
| { | |
| if (stringinput[i] == (char) j + CODE_OF_A) // cast from int to character! | |
| { | |
| uppercase [j]++; | |
| Console.WriteLine (uppercase[j]); | |
| } | |
| else if (stringinput[i] == (char) j + CODE_OF_a) | |
| { | |
| lowercase [j]++; | |
| Console.WriteLine (lowercase[j]); | |
| } | |
| } | |
| } | |
| } | |
| public static void Main (string[] args) | |
| { | |
| Userinput (); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment