Эх сурвалжийг харах

Добавьте файлы проекта.

Сергеичевад 2 жил өмнө
parent
commit
e4b2fa2ca5

+ 25 - 0
ExamSergeichev.sln

@@ -0,0 +1,25 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 17
+VisualStudioVersion = 17.2.32526.322
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ExamSergeichev", "ExamSergeichev\ExamSergeichev.csproj", "{D1839EB0-6C16-43DC-8806-E4654329F08E}"
+EndProject
+Global
+	GlobalSection(SolutionConfigurationPlatforms) = preSolution
+		Debug|Any CPU = Debug|Any CPU
+		Release|Any CPU = Release|Any CPU
+	EndGlobalSection
+	GlobalSection(ProjectConfigurationPlatforms) = postSolution
+		{D1839EB0-6C16-43DC-8806-E4654329F08E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{D1839EB0-6C16-43DC-8806-E4654329F08E}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{D1839EB0-6C16-43DC-8806-E4654329F08E}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{D1839EB0-6C16-43DC-8806-E4654329F08E}.Release|Any CPU.Build.0 = Release|Any CPU
+	EndGlobalSection
+	GlobalSection(SolutionProperties) = preSolution
+		HideSolutionNode = FALSE
+	EndGlobalSection
+	GlobalSection(ExtensibilityGlobals) = postSolution
+		SolutionGuid = {5A2374FC-0B40-45A8-ACF3-196246EF5671}
+	EndGlobalSection
+EndGlobal

+ 10 - 0
ExamSergeichev/ExamSergeichev.csproj

@@ -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>

+ 32 - 0
ExamSergeichev/Program.cs

@@ -0,0 +1,32 @@
+using System;
+
+namespace ExamSergeichev
+{
+    class program
+    {
+        public struct Pipes
+        {
+            public string name;
+            public int length;
+            public double diameter;
+            public double thickness;
+            public string isDefective;
+            public bool isReinforced;
+        }
+
+
+        static void Main(string[] args)
+        {
+            Pipes[] pipe = new Pipes[0];
+            pipe = ReadData.Read("data.txt", ref pipe);
+            int i = 1;
+            foreach (Pipes pip in pipe)
+            {
+                Console.WriteLine("");
+            }
+            marriage obg = new marriage();
+            obg.checkMarriage(ref pipe);
+
+        }
+    }
+}

+ 93 - 0
ExamSergeichev/marriage.cs

@@ -0,0 +1,93 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ExamSergeichev
+{
+   
+
+    internal class marriage
+    {
+        public void checkMarriage(ref program.Pipes[] arr)
+        {
+            string[] nameMarriagePipes = new string[1];
+            
+            bool checkDiameter = false;
+            bool checkAll = false;
+            int iterationForNameArray = 0;
+            string length = "Соответствует";
+            string diameter = "Соответствует";
+            string thickness = "Соответствует";
+
+            int[] diameters = new int[] { 20, 25, 32, 40, 50, 63 };
+            Console.WriteLine("В данном списке указываются трубы, которые не соответствуют обозначенным параметрам. Указанные значения в списке являются неверными");
+            Console.WriteLine("");
+            for (int i = 0; i<arr.Length;i++)
+            {
+                
+
+                if (arr[i].length < 3960 || arr[i].length > 4040)
+                {
+                    length = Convert.ToString(arr[i].length);
+                    checkAll = true;
+                }    
+                
+                for (int j = 0; j<diameters.Length; j++)
+                {
+                    if (arr[i].diameter == diameters[j])
+                    {
+                        checkDiameter = true;
+                        checkAll = true;
+                        break;
+                    }
+                }
+                
+                if (checkDiameter == false) diameter = Convert.ToString(arr[i].diameter);
+
+                if (diameter != "Соответствует") thickness = "Не соответствует, т.к не соответствует внешний диаметр трубы";
+
+                if (arr[i].name == "PN10" && diameter == "Соответствует")
+                {
+                    if (arr[i].thickness < arr[i].diameter * 0.1 && arr[i].thickness > arr[i].diameter * 0.11) thickness = Convert.ToString(arr[i].thickness);
+                    checkAll = true;
+                }
+
+                if (arr[i].name == "PN16" && diameter == "Соответствует")
+                {
+                    if (arr[i].thickness < arr[i].diameter * 0.135 && arr[i].thickness > arr[i].diameter * 0.14) thickness = Convert.ToString(arr[i].thickness);
+                    checkAll = true;
+                }
+
+                if (arr[i].name == "PN20" && diameter == "Соответствует")
+                {
+                    if (arr[i].thickness < arr[i].diameter * 0.165 && arr[i].thickness > arr[i].diameter * 0.17) thickness = Convert.ToString(arr[i].thickness);
+                    checkAll = true;
+                }
+
+                if (arr[i].name == "PN25" && diameter == "Соответствует")
+                {
+                    if (arr[i].thickness < arr[i].diameter * 0.165 && arr[i].thickness > arr[i].diameter * 0.17) thickness = Convert.ToString(arr[i].thickness);
+                    checkAll = true;
+                }
+
+                if (checkAll == true)
+                {
+                    nameMarriagePipes[iterationForNameArray] = arr[i].name;
+                    arr[i].isDefective = "Не соответствует";
+                    Console.WriteLine($"Номер в списке: {i+1} Наименование трубы: {nameMarriagePipes[iterationForNameArray]}, Длина трубы: {length}, Диаметр трубы: {diameter}, Толщина трубы: {thickness}");
+                    checkAll = false;
+                    checkDiameter = false;
+                    i++;
+                    iterationForNameArray++;
+                    Array.Resize(ref nameMarriagePipes, nameMarriagePipes.Length + 1);
+                }
+                else
+                {
+                    i++;
+                }
+            }
+        }
+    }
+}

+ 42 - 0
ExamSergeichev/readDocument.cs

@@ -0,0 +1,42 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.IO;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ExamSergeichev
+{
+    internal class ReadData
+    {
+        static public program.Pipes[] Read(string path, ref program.Pipes[] arr)
+        {
+            if (!File.Exists(path))
+            {
+                Console.WriteLine("Файла не существует!");
+                Environment.Exit(0);
+            }
+            var lines = File.ReadAllLines(path);
+            int i = 0;
+            foreach (var line in lines)
+            {
+                Array.Resize(ref arr, arr.Length + 1);
+                string[] parts = line.Split(";");
+                arr[i].name = parts[0];
+                arr[i].length = Convert.ToInt32(parts[1]);
+                arr[i].diameter = Convert.ToDouble(parts[2]);
+                arr[i].thickness = Convert.ToDouble(parts[3]);
+                if (String.IsNullOrEmpty(parts[4]))
+                {
+                    arr[i].isReinforced = false;
+                }
+                else
+                {
+                    arr[i].isReinforced = true;
+                }
+                i++;
+            }
+            return arr;
+        }
+    }
+}