[Л/Р 2] Островская Софья #18

Merged
v.moiseev merged 2 commits from ostrovsofa/distributed-computing:ostrovskaya-sf-lab-2 into main 2023-11-19 21:56:45 +04:00
3 changed files with 6 additions and 31 deletions
Showing only changes of commit 685fd6ab9b - Show all commits

View File

@ -1,5 +0,0 @@
{
"version": 1,
"isRoot": true,
"tools": {}
}

View File

@ -2,11 +2,11 @@
using System.IO;
using System.Net.Http;
var dir = new DirectoryInfo("../var/data");
var dir = new DirectoryInfo("/var/data");
var files = dir.GetFiles();
string resultFilePath = "../var/result/data.txt";
string resultFilePath = "/var/result/data.txt";
try
{
int[] mass = new int[files.Length];

View File

@ -1,32 +1,12 @@
using System;
using System.IO;
using System.Linq;
string[] lines = File.ReadAllLines("../var/data/data.txt");
string[] lines = File.ReadAllLines("/var/data/data.txt");
int firstNumber = 0;
int lastNumber = 0;
int multiplication = Convert.ToInt32(lines.First()) * Convert.ToInt32(lines.Last());
foreach (string line in lines)
{
if (int.TryParse(line, out int number))
{
firstNumber = number;
break;
}
}
for (int i = lines.Length - 1; i >= 0; i--)
{
if (int.TryParse(lines[i], out int number))
{
lastNumber = number;
break;
}
}
int multiplication = firstNumber * lastNumber;
using (StreamWriter writer = new StreamWriter("../var/result/result.txt"))
using (StreamWriter writer = new StreamWriter("/var/result/result.txt"))

Если мы говорим про C# и коллекции, можно воспользоваться методами .First() и .Last()

(Можно не исправлять)

Если мы говорим про C# и коллекции, можно воспользоваться методами `.First()` и `.Last()` *(Можно не исправлять)*
{
writer.WriteLine(multiplication);
}