Próbuję sobie zrobić te zadanko: http://www.codeabbey.com/index/task_view/matching-words
I dla danych testowych mój program wyświetla poprawne wyjście, jednak przy próbie wykonania go z poziomu strony nie działa (nie wyrzuca nic jako output). Czy ktoś wie czemu tak się dzieje?
using System;
using System.Collections.Generic;
namespace test
{
class Program
{
static void Main(string[] args)
{
string[] input = Console.ReadLine().Split();
List<string> answers = new List<string>();
foreach(string s in input)
{
int index = 0;
for (int i = 0; i != input.Length; i++)
{
if(s == input[i])
{
index++;
if(index == 2)
{
index = 0;
answers.Add(input[i]);
}
}
}
}
answers.Sort();
string[] sx = answers.ToArray();
for (int i = 0; i != sx.Length; i+=2)
{
try
{
answers.RemoveAt(i);
}
catch {}
}
foreach (string s in answers) Console.Write(s + " ");
}
}
}