Initial commit

This commit is contained in:
root 2024-11-29 23:29:09 +00:00
commit 30c54f92b1
12 changed files with 291 additions and 0 deletions

7
Dockerfile Normal file
View File

@ -0,0 +1,7 @@
FROM jenkins/jenkins:lts
USER root
RUN apt-get update && apt-get install -y docker.io && apt-get clean && rm -rf /var/lib/apt/lists/*
USER jenkins

View File

@ -0,0 +1,27 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.11.0" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="3.1.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\MaxElementAboveDiagonal\MaxElementAboveDiagonal.csproj" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,17 @@
using Xunit;
namespace MaxElementAboveDiagonal.Tests;
public class MatrixTests
{
[Fact]
public void TestFindMaxAboveDiagonal()
{
int[,] matrix = {
{ 1, 2, 3 },
{ 4, 5, 6 },
{ 7, 8, 9 }
};
Assert.Equal(6, Program.FindMaxAboveDiagonal(matrix));
}
}

View File

@ -0,0 +1,12 @@
# Dockerfile
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
WORKDIR /app
COPY *.csproj ./
RUN dotnet restore
COPY . ./
RUN dotnet publish -c Release -o out
FROM mcr.microsoft.com/dotnet/runtime:6.0 AS final
WORKDIR /app
COPY --from=build /app/out .
ENTRYPOINT ["dotnet", "MaxElementAboveDiagonal.dll"]

View File

@ -0,0 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>

View File

@ -0,0 +1,68 @@
using System;
namespace MaxElementAboveDiagonal
{
class Program
{
static void Main(string[] args)
{
int size = 5; // Размер матрицы
int[,] matrix = GenerateRandomMatrix(size);
PrintMatrix(matrix);
int maxElement = FindMaxAboveDiagonal(matrix);
Console.WriteLine($"Максимальный элемент выше главной диагонали: {maxElement}");
}
static int[,] GenerateRandomMatrix(int size)
{
Random rand = new Random();
int[,] matrix = new int[size, size];
for (int i = 0; i < size; i++)
{
for (int j = 0; j < size; j++)
{
matrix[i, j] = rand.Next(1, 101); // Случайные числа от 1 до 100
}
}
return matrix;
}
static void PrintMatrix(int[,] matrix)
{
int size = matrix.GetLength(0);
for (int i = 0; i < size; i++)
{
for (int j = 0; j < size; j++)
{
Console.Write($"{matrix[i, j]} ");
}
Console.WriteLine();
}
}
static int FindMaxAboveDiagonal(int[,] matrix)
{
int size = matrix.GetLength(0);
int max = int.MinValue;
for (int i = 0; i < size; i++)
{
for (int j = i + 1; j < size; j++) // Ищем элементы выше главной диагонали
{
if (matrix[i, j] > max)
{
max = matrix[i, j];
}
}
}
return max;
}
}
}

View File

@ -0,0 +1,60 @@
{
"format": 1,
"restore": {
"/root/matrix/MaxElementAboveDiagonal/MaxElementAboveDiagonal.csproj": {}
},
"projects": {
"/root/matrix/MaxElementAboveDiagonal/MaxElementAboveDiagonal.csproj": {
"version": "1.0.0",
"restore": {
"projectUniqueName": "/root/matrix/MaxElementAboveDiagonal/MaxElementAboveDiagonal.csproj",
"projectName": "MaxElementAboveDiagonal",
"projectPath": "/root/matrix/MaxElementAboveDiagonal/MaxElementAboveDiagonal.csproj",
"packagesPath": "/root/.nuget/packages/",
"outputPath": "/root/matrix/MaxElementAboveDiagonal/obj/",
"projectStyle": "PackageReference",
"configFilePaths": [
"/root/.nuget/NuGet/NuGet.Config"
],
"originalTargetFrameworks": [
"net6.0"
],
"sources": {
"https://api.nuget.org/v3/index.json": {}
},
"frameworks": {
"net6.0": {
"targetAlias": "net6.0",
"projectReferences": {}
}
},
"warningProperties": {
"warnAsError": [
"NU1605"
]
}
},
"frameworks": {
"net6.0": {
"targetAlias": "net6.0",
"imports": [
"net461",
"net462",
"net47",
"net471",
"net472",
"net48"
],
"assetTargetFallback": true,
"warn": true,
"frameworkReferences": {
"Microsoft.NETCore.App": {
"privateAssets": "all"
}
},
"runtimeIdentifierGraphPath": "/usr/lib/dotnet/sdk/6.0.135/RuntimeIdentifierGraph.json"
}
}
}
}
}

View File

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
<RestoreSuccess Condition=" '$(RestoreSuccess)' == '' ">True</RestoreSuccess>
<RestoreTool Condition=" '$(RestoreTool)' == '' ">NuGet</RestoreTool>
<ProjectAssetsFile Condition=" '$(ProjectAssetsFile)' == '' ">$(MSBuildThisFileDirectory)project.assets.json</ProjectAssetsFile>
<NuGetPackageRoot Condition=" '$(NuGetPackageRoot)' == '' ">/root/.nuget/packages/</NuGetPackageRoot>
<NuGetPackageFolders Condition=" '$(NuGetPackageFolders)' == '' ">/root/.nuget/packages/</NuGetPackageFolders>
<NuGetProjectStyle Condition=" '$(NuGetProjectStyle)' == '' ">PackageReference</NuGetProjectStyle>
<NuGetToolVersion Condition=" '$(NuGetToolVersion)' == '' ">6.0.6</NuGetToolVersion>
</PropertyGroup>
<ItemGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
<SourceRoot Include="/root/.nuget/packages/" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" />

View File

@ -0,0 +1,65 @@
{
"version": 3,
"targets": {
"net6.0": {}
},
"libraries": {},
"projectFileDependencyGroups": {
"net6.0": []
},
"packageFolders": {
"/root/.nuget/packages/": {}
},
"project": {
"version": "1.0.0",
"restore": {
"projectUniqueName": "/root/matrix/MaxElementAboveDiagonal/MaxElementAboveDiagonal.csproj",
"projectName": "MaxElementAboveDiagonal",
"projectPath": "/root/matrix/MaxElementAboveDiagonal/MaxElementAboveDiagonal.csproj",
"packagesPath": "/root/.nuget/packages/",
"outputPath": "/root/matrix/MaxElementAboveDiagonal/obj/",
"projectStyle": "PackageReference",
"configFilePaths": [
"/root/.nuget/NuGet/NuGet.Config"
],
"originalTargetFrameworks": [
"net6.0"
],
"sources": {
"https://api.nuget.org/v3/index.json": {}
},
"frameworks": {
"net6.0": {
"targetAlias": "net6.0",
"projectReferences": {}
}
},
"warningProperties": {
"warnAsError": [
"NU1605"
]
}
},
"frameworks": {
"net6.0": {
"targetAlias": "net6.0",
"imports": [
"net461",
"net462",
"net47",
"net471",
"net472",
"net48"
],
"assetTargetFallback": true,
"warn": true,
"frameworkReferences": {
"Microsoft.NETCore.App": {
"privateAssets": "all"
}
},
"runtimeIdentifierGraphPath": "/usr/lib/dotnet/sdk/6.0.135/RuntimeIdentifierGraph.json"
}
}
}
}

View File

@ -0,0 +1,8 @@
{
"version": 2,
"dgSpecHash": "8zZAWzEzCaGQxrSoPp6LvimWHLWa9gwirNhnnVGFO+fY0ZfwcdCyDQevOI/iNKdyNo85jAlmSIVhloIsb+lHDA==",
"success": true,
"projectFilePath": "/root/matrix/MaxElementAboveDiagonal/MaxElementAboveDiagonal.csproj",
"expectedPackageFiles": [],
"logs": []
}

BIN
max-element-app.tar Normal file

Binary file not shown.