Skip to content

Instantly share code, notes, and snippets.

@d8ta
Created February 27, 2014 09:17
Show Gist options
  • Save d8ta/9246869 to your computer and use it in GitHub Desktop.
Save d8ta/9246869 to your computer and use it in GitHub Desktop.
Aufgabe 2: RLE
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