wineconsole --backend=curses DCon.exe
<?php
List<string> names;
List<Int32> scores;
foreach(file)
{
foreach(line)
{
names.Add(name);
scores.Add(Convert.Int32(line));
}
}
Array.Sort(scores, names);
?>
<?php
using System;
using System.Collections.Generic;
using System.IO;
public class PlayersScore : IComparable
{
public string Name { get; set; }
public Int32 Score { get; set; }
public PlayersScore(string Name, Int32 Score)
{
this.Name = Name;
this.Score = Score;
}
public int CompareTo(Object other)
{
PlayersScore otherS = null;
try
{
otherS = (PlayersScore)other;
}
catch (InvalidCastException ex)
{
throw ex;
}
if (this.Score < otherS.Score)
return -1;
else if (this.Score > otherS.Score)
return 1;
else
return String.Compare(this.Name, otherS.Name, System.StringComparison.OrdinalIgnoreCase);
}
}
public class SortScores
{
static int Main()
{
List<PlayersScore> scores = new List<PlayersScore>();
string[] files = Directory.GetFiles(@"./", "*.txt");
if (files.Length < 1)
{
Console.WriteLine("No files.");
return 1;
}
foreach(string f in files)
{
string name = f.Substring(2, f.Length - 6);
string[] lines;
try
{
lines = System.IO.File.ReadAllLines(f);
}
catch (Exception ex)
{
Console.WriteLine("File \"" + f.Substring(2) + "\" cannot be read.");
Console.WriteLine(ex.ToString());
continue;
}
foreach(string line in lines)
{
Int32 score;
try
{
score = Convert.ToInt32(line);
}
catch (Exception ex)
{
Console.WriteLine("Line \"" + line + "\" cannot be converted to Int32.");
Console.WriteLine(ex.ToString());
continue;
}
scores.Add(new PlayersScore(name, score));
}
}
scores.Sort();
foreach(PlayersScore ps in scores)
{
Console.WriteLine(ps.Score + " (" + ps.Name + ")");
}
return 0;
}
}
?>