2 лаб
This commit is contained in:
parent
ae5a52f365
commit
7a6fa0a5e4
13
tasks/kazakov-ev/lab_2/docker-compose.yml
Normal file
13
tasks/kazakov-ev/lab_2/docker-compose.yml
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
version: "3.1"
|
||||||
|
services:
|
||||||
|
worker-1:
|
||||||
|
build: ./worker-1
|
||||||
|
volumes:
|
||||||
|
- ./data:/var/data
|
||||||
|
- ./result:/var/result
|
||||||
|
worker-2:
|
||||||
|
build: ./worker-2
|
||||||
|
volumes:
|
||||||
|
- ./result:/var/result
|
||||||
|
depends_on:
|
||||||
|
- worker-1
|
3
tasks/kazakov-ev/lab_2/var/data/test1.txt
Normal file
3
tasks/kazakov-ev/lab_2/var/data/test1.txt
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
1
|
||||||
|
2
|
||||||
|
3
|
5
tasks/kazakov-ev/lab_2/var/data/test2.txt
Normal file
5
tasks/kazakov-ev/lab_2/var/data/test2.txt
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
1
|
||||||
|
1
|
||||||
|
1
|
||||||
|
1
|
||||||
|
1
|
10
tasks/kazakov-ev/lab_2/var/data/test3.txt
Normal file
10
tasks/kazakov-ev/lab_2/var/data/test3.txt
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
10
|
||||||
|
10
|
||||||
|
10
|
||||||
|
10
|
||||||
|
10
|
||||||
|
10
|
||||||
|
10
|
||||||
|
10
|
||||||
|
10
|
||||||
|
10
|
@ -1,2 +1,22 @@
|
|||||||
// See https://aka.ms/new-console-template for more information
|
using System.Text;
|
||||||
Console.WriteLine("Hello, World!");
|
|
||||||
|
string[] files = Directory.GetFiles("/var/data");
|
||||||
|
string maxFilePath = "";
|
||||||
|
long maxL = 0;
|
||||||
|
foreach(var filePath in files){
|
||||||
|
FileInfo fileInfo = new FileInfo(filePath);
|
||||||
|
if(fileInfo.Length > maxL){
|
||||||
|
maxL = fileInfo.Length;
|
||||||
|
maxFilePath = filePath;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
using (FileStream fstream = File.OpenRead(maxFilePath)){
|
||||||
|
byte[] buffer = new byte[fstream.Length];
|
||||||
|
await fstream.ReadAsync(buffer, 0, buffer.Length);
|
||||||
|
string text = Encoding.Default.GetString(buffer);
|
||||||
|
using(FileStream fstream1 = new FileStream("/var/result/data.txt", FileMode.OpenOrCreate)){
|
||||||
|
fstream1.SetLength(0);
|
||||||
|
byte[] buffer1 = Encoding.Default.GetBytes(text);
|
||||||
|
await fstream1.WriteAsync(buffer1, 0, buffer1.Length);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -1,2 +1,23 @@
|
|||||||
// See https://aka.ms/new-console-template for more information
|
using System.Text;
|
||||||
Console.WriteLine("Hello, World!");
|
|
||||||
|
int[] numbers = File.ReadAllLines("../../../../var/data/data.txt").Select(x=> int.Parse(x)).ToArray();
|
||||||
|
int maxNumber = 0;
|
||||||
|
int maxNumberCount = 0;
|
||||||
|
foreach(var number in numbers){
|
||||||
|
if(number < maxNumber){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if(number == maxNumber){
|
||||||
|
maxNumberCount++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if(number > maxNumber){
|
||||||
|
maxNumber = number;
|
||||||
|
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);
|
||||||
|
Loading…
Reference in New Issue
Block a user