distributed-computing/tasks/khalitova-am/lab_2/worker-2/Program.cs

23 lines
702 B
C#
Raw Normal View History

2023-10-03 23:36:51 +04:00
using System.Text;
2023-10-16 20:20:21 +04:00
int[] numbers = File.ReadAllLines("../../../../var/data/data.txt").Select(x=> int.Parse(x)).ToArray();
2023-10-03 23:36:51 +04:00
int maxNumber = 0;
int maxNumberCount = 0;
foreach(var number in numbers){
2023-10-16 20:20:21 +04:00
if(number < maxNumber){
2023-10-03 23:36:51 +04:00
continue;
}
2023-10-16 20:20:21 +04:00
if(number == maxNumber){
2023-10-03 23:36:51 +04:00
maxNumberCount++;
continue;
}
2023-10-16 20:20:21 +04:00
if(number > maxNumber){
maxNumber = number;
2023-10-03 23:36:51 +04:00
maxNumberCount = 1;
}
}
using(FileStream fstream = new FileStream("../../../../var/result/result.txt", FileMode.OpenOrCreate)){
byte[] buffer = Encoding.Default.GetBytes(maxNumberCount.ToString());
await fstream.WriteAsync(buffer, 0, buffer.Length);
}
Console.WriteLine(maxNumberCount);