프로그래밍/C#

C# 역문자열

코딩줌마 2019. 3. 24. 08:56

StreamReader file = new StreamReader("input.txt");
int size = Int32.Parse(file.ReadLine());
List<string> list = new List<string>();

while (!file.EndOfStream)
{
list.Add(file.ReadLine());
}

for (int i = 0; i < list.Count-1; i++)
{
String rev = new String(list[i].ToCharArray().Reverse().ToArray());
for(int j=i+1;i<list.Count;j++)
{
if (rev == list[j])
{
int length = list[j].Length;
Console.WriteLine(length+ " "+list[j][(int)length / 2]);
file.Close();
return;
}
}
}
file.Close();

반응형