24 lines
803 B
C#
24 lines
803 B
C#
using System.Text;
|
|
|
|
string[] numbers;
|
|
using (FileStream fstream = File.OpenRead("../../../../var/result/data.txt")){
|
|
byte[] buffer = new byte[fstream.Length];
|
|
await fstream.ReadAsync(buffer, 0, buffer.Length);
|
|
string text = Encoding.Default.GetString(buffer);
|
|
text = text.Replace("\r\n",";");
|
|
numbers = text.Split(new char[]{';'});
|
|
}
|
|
int maxNumber = 0;
|
|
int n = 0;
|
|
foreach(var number in numbers){
|
|
if(Convert.ToInt32(number) > maxNumber){
|
|
maxNumber = Convert.ToInt32(number);
|
|
n = maxNumber*maxNumber;
|
|
}
|
|
}
|
|
using(FileStream fstream = new FileStream("../../../../var/result/result.txt", FileMode.OpenOrCreate)){
|
|
byte[] buffer = Encoding.Default.GetBytes(n.ToString());
|
|
await fstream.WriteAsync(buffer, 0, buffer.Length);
|
|
}
|
|
Console.WriteLine(n);
|