online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code    Language
using System; namespace MyApp { internal class Program { static void Main(string[] args) { const string text = "tttesst"; string uniqChars = FindDistinctLetters(text); // uniqChars t e s int[] numbers = FindNumberOfEachLetter(text, uniqChars); // CharsOccurance 4 1 2 int maximofelements = AreEnoughLetters(numbers,text.Length); char[] nou = new char[text.Length]; if (maximofelements > -1) { Console.WriteLine(uniqChars[maximofelements]); } Console.WriteLine(GetFinalString(numbers, uniqChars)); } static string FindDistinctLetters(string text) { string distinctLetters = ""; for (int i = 0; i < text.Length; i++) { if (!distinctLetters.Contains(text[i])) { distinctLetters = distinctLetters + text[i]; } } // Console.WriteLine(distinctLetters); return distinctLetters; } static int[] FindNumberOfEachLetter(string text, string unique) { int count = 0; int[] rezult = new int[unique.Length]; for (int i = 0; i < unique.Length; i++) { count = 0; for (int j = 0; j < text.Length; j++) { if (unique[i] == text[j]) { count++; } } rezult[i] = count; //Console.WriteLine(rezult[i]); } return rezult; } static int AreEnoughLetters(int[] numbers, int arrayLength) // Check if one element occurs more then 50% { int maxLenghtindex = 0; int minimumsizereq = 0; if (arrayLength % 2 == 0) { minimumsizereq = arrayLength / 2; } else { minimumsizereq = (arrayLength / 2) + 2; } int index = 0; for (int i = 0; i < numbers.Length; i++) { if (numbers[i] > maxLenghtindex) { maxLenghtindex = numbers[i]; index = i; } } if (minimumsizereq > maxLenghtindex) { return -1; } return index; } static string GetFinalString(int[] numberofChars, string uniqChars) { string final = ""; int numberofFreqChar = 0; int indexOfMostFreqChar = 0; for (int i = 0; i < numberofChars.Length; i++) { if (numberofFreqChar < numberofChars[i]) { numberofFreqChar = numberofChars[i]; indexOfMostFreqChar = i; } } Console.WriteLine("the element {0}", uniqChars[indexOfMostFreqChar]); Console.WriteLine("found at index {0} in the array called Numbers ", indexOfMostFreqChar); Console.WriteLine("is repeating {0} times ", numberofFreqChar); return final; } } }

Compiling Program...

Command line arguments:
Standard Input: Interactive Console Text
×

                

                

Program is not being debugged. Click "Debug" button to start program in debug mode.

#FunctionFile:Line
VariableValue
RegisterValue
ExpressionValue