using System using System Collections Generic using System IO using Sy

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace RosalinaCSharp
{
class Program
{
static void Main(string[] args)
{
int totalCount = -1;
int maxDay = 0;
string lastName = "";
StreamReader file = new StreamReader("input.txt");
StreamWriter outFile = new StreamWriter("output.txt");
string line;
while((line = file.ReadLine()) != null)
{
string[] bits = line.Split(' ');
int tmpTotalCount = 0;
int tmpMaxDay = 1;
string tmpLastName = bits[0];
for (int i = 1; i < bits.Length; i++)
{
tmpTotalCount += int.Parse(bits[i]);
if (int.Parse(bits[i]) > int.Parse(bits[tmpMaxDay]))
{
tmpMaxDay = i;
}
}
if (tmpTotalCount > totalCount)
{
totalCount = tmpTotalCount;
lastName = tmpLastName;
maxDay = tmpMaxDay;
}
outFile.WriteLine(lastName + ", всего деталей: " + tmpTotalCount);
}
outFile.WriteLine("Лучший: " + lastName + ", номер дня недели: " + (maxDay + 1));
outFile.Close();
file.Close();
}
}
}