This commit is contained in:
nik
2025-09-30 14:26:54 +03:00
parent 8bd93df2ae
commit 8164e04835
633 changed files with 8 additions and 8 deletions

View File

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

View File

@@ -0,0 +1,87 @@
using System;
public class Program
{
static int SumPos(int[] a)
{
int r = 0;
foreach (int x in a) if (x > 0) r += x;
return r;
}
static int SumNeg(int[] a)
{
int r = 0;
foreach (int x in a) if (x < 0) r += x;
return r;
}
static int SumArr(int[] a) => SumPos(a) + SumNeg(a);
static double AvgArr(int[] a) => a.Length == 0 ? double.NaN : (double)SumArr(a) / a.Length;
static int SumEvenPos(int[] a)
{
int r = 0;
for (int i = 0; i < a.Length; i += 2) r += a[i];
return r;
}
static int SumOddPos(int[] a)
{
int r = 0;
for (int i = 1; i < a.Length; i += 2) r += a[i];
return r;
}
static int MaxIdx(int[] a)
{
if (a.Length == 0) return -1;
int idx = 0, m = a[0];
for (int i = 1; i < a.Length; i++)
if (a[i] > m) { m = a[i]; idx = i; }
return idx;
}
static int MinIdx(int[] a)
{
if (a.Length == 0) return -1;
int idx = 0, m = a[0];
for (int i = 1; i < a.Length; i++)
if (a[i] < m) { m = a[i]; idx = i; }
return idx;
}
static int ProductBetweenMinMax(int[] a)
{
int start = MinIdx(a), end = MaxIdx(a);
if (start == -1 || end == -1) return -1;
if (start > end) { int t = start; start = end; end = t; }
if (end - start <= 1) return -1;
int r = 1;
for (int i = start + 1; i < end; i++) r *= a[i];
return r;
}
public static void Main(string[] args)
{
Console.Write("input an arr length: ");
int n = int.Parse(Console.ReadLine());
int[] arr = new int[n];
for (int i = 0; i < arr.Length; i++)
{
Console.Write("arr[{0}] = ", i);
arr[i] = int.Parse(Console.ReadLine());
}
Console.WriteLine("sum of the array's elements is {0}", SumArr(arr));
Console.WriteLine("avg value of the array is {0}", AvgArr(arr));
Console.WriteLine("sum of positive array values is {0}, sum of negative array values is {1}", SumPos(arr), SumNeg(arr));
Console.WriteLine("sum of elements on even positions is {0}, sum of elements on odd positions is {1}", SumEvenPos(arr), SumOddPos(arr));
Console.WriteLine("index of max array element is {0}", MaxIdx(arr));
Console.WriteLine("index of min array element is {0}", MinIdx(arr));
Console.WriteLine("product of numbers between min and max is {0}", ProductBetweenMinMax(arr));
}
}

Binary file not shown.

View File

@@ -0,0 +1,23 @@
{
"runtimeTarget": {
"name": ".NETCoreApp,Version=v9.0",
"signature": ""
},
"compilationOptions": {},
"targets": {
".NETCoreApp,Version=v9.0": {
"ArrayProcess/1.0.0": {
"runtime": {
"ArrayProcess.dll": {}
}
}
}
},
"libraries": {
"ArrayProcess/1.0.0": {
"type": "project",
"serviceable": false,
"sha512": ""
}
}
}

View File

@@ -0,0 +1,12 @@
{
"runtimeOptions": {
"tfm": "net9.0",
"framework": {
"name": "Microsoft.NETCore.App",
"version": "9.0.0"
},
"configProperties": {
"System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization": false
}
}
}

View File

@@ -0,0 +1,73 @@
{
"format": 1,
"restore": {
"/home/nik/oop/labs/lab5/ArrayProcess/ArrayProcess.csproj": {}
},
"projects": {
"/home/nik/oop/labs/lab5/ArrayProcess/ArrayProcess.csproj": {
"version": "1.0.0",
"restore": {
"projectUniqueName": "/home/nik/oop/labs/lab5/ArrayProcess/ArrayProcess.csproj",
"projectName": "ArrayProcess",
"projectPath": "/home/nik/oop/labs/lab5/ArrayProcess/ArrayProcess.csproj",
"packagesPath": "/home/nik/.nuget/packages/",
"outputPath": "/home/nik/oop/labs/lab5/ArrayProcess/obj/",
"projectStyle": "PackageReference",
"configFilePaths": [
"/home/nik/.nuget/NuGet/NuGet.Config"
],
"originalTargetFrameworks": [
"net9.0"
],
"sources": {
"https://api.nuget.org/v3/index.json": {}
},
"frameworks": {
"net9.0": {
"targetAlias": "net9.0",
"projectReferences": {}
}
},
"warningProperties": {
"warnAsError": [
"NU1605"
]
},
"restoreAuditProperties": {
"enableAudit": "true",
"auditLevel": "low",
"auditMode": "direct"
},
"SdkAnalysisLevel": "9.0.100"
},
"frameworks": {
"net9.0": {
"targetAlias": "net9.0",
"imports": [
"net461",
"net462",
"net47",
"net471",
"net472",
"net48",
"net481"
],
"assetTargetFallback": true,
"warn": true,
"downloadDependencies": [
{
"name": "Microsoft.AspNetCore.App.Ref",
"version": "[9.0.9, 9.0.9]"
}
],
"frameworkReferences": {
"Microsoft.NETCore.App": {
"privateAssets": "all"
}
},
"runtimeIdentifierGraphPath": "/usr/share/dotnet/sdk/9.0.110/PortableRuntimeIdentifierGraph.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)' == '' ">/home/nik/.nuget/packages/</NuGetPackageRoot>
<NuGetPackageFolders Condition=" '$(NuGetPackageFolders)' == '' ">/home/nik/.nuget/packages/</NuGetPackageFolders>
<NuGetProjectStyle Condition=" '$(NuGetProjectStyle)' == '' ">PackageReference</NuGetProjectStyle>
<NuGetToolVersion Condition=" '$(NuGetToolVersion)' == '' ">6.12.4</NuGetToolVersion>
</PropertyGroup>
<ItemGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
<SourceRoot Include="/home/nik/.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,4 @@
// <autogenerated />
using System;
using System.Reflection;
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v9.0", FrameworkDisplayName = ".NET 9.0")]

View File

@@ -0,0 +1,22 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
using System;
using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("ArrayProcess")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+1c467e61be36ba28401de8950c829e3f753a634c")]
[assembly: System.Reflection.AssemblyProductAttribute("ArrayProcess")]
[assembly: System.Reflection.AssemblyTitleAttribute("ArrayProcess")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
// Generated by the MSBuild WriteCodeFragment class.

View File

@@ -0,0 +1 @@
bc1a894a07e31dbe1db6119b8c6b5279570fae72bc5f8b74a790bdc4b9be740a

View File

@@ -0,0 +1,15 @@
is_global = true
build_property.TargetFramework = net9.0
build_property.TargetPlatformMinVersion =
build_property.UsingMicrosoftNETSdkWeb =
build_property.ProjectTypeGuids =
build_property.InvariantGlobalization =
build_property.PlatformNeutralAssembly =
build_property.EnforceExtendedAnalyzerRules =
build_property._SupportedPlatformList = Linux,macOS,Windows
build_property.RootNamespace = ArrayProcess
build_property.ProjectDir = /home/nik/oop/labs/lab5/ArrayProcess/
build_property.EnableComHosting =
build_property.EnableGeneratedComInterfaceComImportInterop =
build_property.EffectiveAnalysisLevelStyle = 9.0
build_property.EnableCodeStyleSeverity =

View File

@@ -0,0 +1,8 @@
// <auto-generated/>
global using global::System;
global using global::System.Collections.Generic;
global using global::System.IO;
global using global::System.Linq;
global using global::System.Net.Http;
global using global::System.Threading;
global using global::System.Threading.Tasks;

View File

@@ -0,0 +1 @@
f938326882807c5adf4897670d20ed14ffc9ca82b09145183737ae80fdead58f

View File

@@ -0,0 +1,14 @@
/home/nik/oop/labs/lab5/ArrayProcess/bin/Debug/net9.0/ArrayProcess
/home/nik/oop/labs/lab5/ArrayProcess/bin/Debug/net9.0/ArrayProcess.deps.json
/home/nik/oop/labs/lab5/ArrayProcess/bin/Debug/net9.0/ArrayProcess.runtimeconfig.json
/home/nik/oop/labs/lab5/ArrayProcess/bin/Debug/net9.0/ArrayProcess.dll
/home/nik/oop/labs/lab5/ArrayProcess/bin/Debug/net9.0/ArrayProcess.pdb
/home/nik/oop/labs/lab5/ArrayProcess/obj/Debug/net9.0/ArrayProcess.GeneratedMSBuildEditorConfig.editorconfig
/home/nik/oop/labs/lab5/ArrayProcess/obj/Debug/net9.0/ArrayProcess.AssemblyInfoInputs.cache
/home/nik/oop/labs/lab5/ArrayProcess/obj/Debug/net9.0/ArrayProcess.AssemblyInfo.cs
/home/nik/oop/labs/lab5/ArrayProcess/obj/Debug/net9.0/ArrayProcess.csproj.CoreCompileInputs.cache
/home/nik/oop/labs/lab5/ArrayProcess/obj/Debug/net9.0/ArrayProcess.dll
/home/nik/oop/labs/lab5/ArrayProcess/obj/Debug/net9.0/refint/ArrayProcess.dll
/home/nik/oop/labs/lab5/ArrayProcess/obj/Debug/net9.0/ArrayProcess.pdb
/home/nik/oop/labs/lab5/ArrayProcess/obj/Debug/net9.0/ArrayProcess.genruntimeconfig.cache
/home/nik/oop/labs/lab5/ArrayProcess/obj/Debug/net9.0/ref/ArrayProcess.dll

View File

@@ -0,0 +1 @@
1c60a15cf2f24d58cb1e6ea8e943d82b4a6455334a8d210a750368ceb6e13d26

Binary file not shown.

View File

@@ -0,0 +1,78 @@
{
"version": 3,
"targets": {
"net9.0": {}
},
"libraries": {},
"projectFileDependencyGroups": {
"net9.0": []
},
"packageFolders": {
"/home/nik/.nuget/packages/": {}
},
"project": {
"version": "1.0.0",
"restore": {
"projectUniqueName": "/home/nik/oop/labs/lab5/ArrayProcess/ArrayProcess.csproj",
"projectName": "ArrayProcess",
"projectPath": "/home/nik/oop/labs/lab5/ArrayProcess/ArrayProcess.csproj",
"packagesPath": "/home/nik/.nuget/packages/",
"outputPath": "/home/nik/oop/labs/lab5/ArrayProcess/obj/",
"projectStyle": "PackageReference",
"configFilePaths": [
"/home/nik/.nuget/NuGet/NuGet.Config"
],
"originalTargetFrameworks": [
"net9.0"
],
"sources": {
"https://api.nuget.org/v3/index.json": {}
},
"frameworks": {
"net9.0": {
"targetAlias": "net9.0",
"projectReferences": {}
}
},
"warningProperties": {
"warnAsError": [
"NU1605"
]
},
"restoreAuditProperties": {
"enableAudit": "true",
"auditLevel": "low",
"auditMode": "direct"
},
"SdkAnalysisLevel": "9.0.100"
},
"frameworks": {
"net9.0": {
"targetAlias": "net9.0",
"imports": [
"net461",
"net462",
"net47",
"net471",
"net472",
"net48",
"net481"
],
"assetTargetFallback": true,
"warn": true,
"downloadDependencies": [
{
"name": "Microsoft.AspNetCore.App.Ref",
"version": "[9.0.9, 9.0.9]"
}
],
"frameworkReferences": {
"Microsoft.NETCore.App": {
"privateAssets": "all"
}
},
"runtimeIdentifierGraphPath": "/usr/share/dotnet/sdk/9.0.110/PortableRuntimeIdentifierGraph.json"
}
}
}
}

View File

@@ -0,0 +1,10 @@
{
"version": 2,
"dgSpecHash": "eoTf7zVqGRY=",
"success": true,
"projectFilePath": "/home/nik/oop/labs/lab5/ArrayProcess/ArrayProcess.csproj",
"expectedPackageFiles": [
"/home/nik/.nuget/packages/microsoft.aspnetcore.app.ref/9.0.9/microsoft.aspnetcore.app.ref.9.0.9.nupkg.sha512"
],
"logs": []
}