on master help sign in
first commit
commit857418b192cc7b84be64b4d3a06a5e50c026065a authorilyakooo0 <ilyakooo0@gmail.com> dateThu 7 Jun 2018, 10:37 (8 years ago)
29 files changed+488
unifiedsplit
.vs/KR4/xs/UserPrefs.xml+19 .vs/KR4/xs/sqlite3/db.lock .vs/KR4/xs/sqlite3/storage.ide .vs/KR4/xs/sqlite3/storage.ide-shm .vs/KR4/xs/sqlite3/storage.ide-wal KR4.sln+23 Reader/Data.cs+33 Reader/Processing.cs+66 Reader/Program.cs+50 Reader/Properties/AssemblyInfo.cs+26 Reader/Reader.csproj+41 Reader/bin/Debug/Reader.exe Reader/bin/Debug/Reader.pdb Reader/obj/x86/Debug/Reader.csproj.CoreCompileInputs.cache+1 Reader/obj/x86/Debug/Reader.csproj.FileListAbsolute.txt+5 Reader/obj/x86/Debug/Reader.exe Reader/obj/x86/Debug/Reader.pdb Writer/Program.cs+35 Writer/Properties/AssemblyInfo.cs+26 Writer/Writer.csproj+40 Writer/bin/Debug/Writer.exe Writer/bin/Debug/Writer.pdb Writer/iko.cs+107 Writer/obj/x86/Debug/Writer.csproj.CoreCompileInputs.cache+1 Writer/obj/x86/Debug/Writer.csproj.FileListAbsolute.txt+5 Writer/obj/x86/Debug/Writer.csprojResolveAssemblyReference.cache Writer/obj/x86/Debug/Writer.exe Writer/obj/x86/Debug/Writer.pdb nums.txt+10
.vs/KR4/xs/UserPrefs.xmlnew file+19
@@ -0,0 +1,19 @@
1+<Properties StartupConfiguration="{4B81E1C1-3FE2-44DD-8E70-C59330524D1A}|Default">
2+ <MonoDevelop.Ide.Workbench ActiveDocument="Reader/Program.cs">
3+ <Files>
4+ <File FileName="Writer/Program.cs" Line="1" Column="1" />
5+ <File FileName="Writer/iko.cs" Line="1" Column="1" />
6+ <File FileName="Reader/Program.cs" Line="6" Column="3" />
7+ <File FileName="Reader/Processing.cs" Line="10" Column="10" />
8+ <File FileName="Reader/Data.cs" Line="18" Column="14" />
9+ </Files>
10+ </MonoDevelop.Ide.Workbench>
11+ <MonoDevelop.Ide.Workspace ActiveConfiguration="Debug|x86" />
12+ <MonoDevelop.Ide.DebuggingService.Breakpoints>
13+ <BreakpointStore />
14+ </MonoDevelop.Ide.DebuggingService.Breakpoints>
15+ <MonoDevelop.Ide.DebuggingService.PinnedWatches />
16+ <MonoDevelop.Ide.ItemProperties.Writer PreferredExecutionTarget="MonoDevelop.Default" />
17+ <MultiItemStartupConfigurations />
18+ <MonoDevelop.Ide.ItemProperties.Reader PreferredExecutionTarget="MonoDevelop.Default" />
19+</Properties>
.vs/KR4/xs/sqlite3/db.locknew file

No changes to the content.

.vs/KR4/xs/sqlite3/storage.idenew file

Binary file not shown.

.vs/KR4/xs/sqlite3/storage.ide-shmnew file

Binary file not shown.

.vs/KR4/xs/sqlite3/storage.ide-walnew file

Binary file not shown.

KR4.slnnew file+23
@@ -0,0 +1,23 @@
1+
2+Microsoft Visual Studio Solution File, Format Version 12.00
3+# Visual Studio 2012
4+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Writer", "Writer\Writer.csproj", "{6CBB709C-A8D4-4CE8-ADD0-BD64CA80DAD3}"
5+EndProject
6+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Reader", "Reader\Reader.csproj", "{4B81E1C1-3FE2-44DD-8E70-C59330524D1A}"
7+EndProject
8+Global
9+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+ Debug|x86 = Debug|x86
11+ Release|x86 = Release|x86
12+ EndGlobalSection
13+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+ {6CBB709C-A8D4-4CE8-ADD0-BD64CA80DAD3}.Debug|x86.ActiveCfg = Debug|x86
15+ {6CBB709C-A8D4-4CE8-ADD0-BD64CA80DAD3}.Debug|x86.Build.0 = Debug|x86
16+ {6CBB709C-A8D4-4CE8-ADD0-BD64CA80DAD3}.Release|x86.ActiveCfg = Release|x86
17+ {6CBB709C-A8D4-4CE8-ADD0-BD64CA80DAD3}.Release|x86.Build.0 = Release|x86
18+ {4B81E1C1-3FE2-44DD-8E70-C59330524D1A}.Debug|x86.ActiveCfg = Debug|x86
19+ {4B81E1C1-3FE2-44DD-8E70-C59330524D1A}.Debug|x86.Build.0 = Debug|x86
20+ {4B81E1C1-3FE2-44DD-8E70-C59330524D1A}.Release|x86.ActiveCfg = Release|x86
21+ {4B81E1C1-3FE2-44DD-8E70-C59330524D1A}.Release|x86.Build.0 = Release|x86
22+ EndGlobalSection
23+EndGlobal
Reader/Data.csnew file+33
@@ -0,0 +1,33 @@
1+using System;
2+using System.Linq;
3+
4+namespace Reader {
5+ public class Data {
6+
7+ int[] V;
8+
9+ public double M;
10+ public double D;
11+ public double Z;
12+
13+ public Data(string values) {
14+ char[] separators = {' '};
15+ V = values.Split(separators).Select((n) => int.Parse(n)).ToArray();
16+ if (V.Count() < 1) {
17+ throw new ArgumentException();
18+ }
19+ foreach (var n in V) {
20+ if (n <= 0) {
21+ throw new ArgumentOutOfRangeException();
22+ }
23+ }
24+ M = V.Average();
25+ D = V.Select((n) => (n-M)*(n-M)).Sum() / V.Count();
26+ Z = V.Select((n) => Math.Abs(n-M)).Sum() / V.Count();
27+ }
28+
29+ public override string ToString() {
30+ return $"nums = {String.Join(" ", V.Select((n) => n.ToString()))}\nM = {M}\nD = {D}\nZ = {Z}";
31+ }
32+ }
33+}
Reader/Processing.csnew file+66
@@ -0,0 +1,66 @@
1+using System;
2+using System.IO;
3+using System.Collections.Generic;
4+using System.Collections;
5+
6+namespace Reader {
7+ public class Processing: IEnumerable<Data> {
8+ public Processing(string p) {
9+ path = p;
10+ }
11+
12+ private string path;
13+
14+ IEnumerator<Data> IEnumerable<Data>.GetEnumerator() {
15+ return new ProcessingEnum(path);
16+ }
17+
18+ IEnumerator IEnumerable.GetEnumerator() {
19+ return new ProcessingEnum(path);
20+ }
21+
22+ class ProcessingEnum: IEnumerator<Data> {
23+ StreamReader reader;
24+ string path;
25+ internal ProcessingEnum(string p) {
26+ path = p;
27+ try {
28+ reader = new StreamReader(p);
29+ } catch {
30+ throw new ArgumentException();
31+ }
32+ }
33+
34+ private Data last;
35+
36+ Data IEnumerator<Data>.Current => last;
37+
38+ object IEnumerator.Current => last;
39+
40+ bool IEnumerator.MoveNext() {
41+ if (reader == null) {
42+ throw new InvalidOperationException();
43+ }
44+ var l = reader.ReadLine();
45+ if (l == null) {
46+ reader.Close();
47+ reader = null;
48+ return false;
49+ }
50+ last = new Data(l.Trim());
51+ return last != null;
52+ }
53+
54+ void IEnumerator.Reset() {
55+ try {
56+ reader = new StreamReader(path);
57+ } catch {
58+ throw new ArgumentException();
59+ }
60+ }
61+
62+ void IDisposable.Dispose() {
63+ }
64+ }
65+ }
66+}
Reader/Program.csnew file+50
@@ -0,0 +1,50 @@
1+/*
2+ФИО: Костюченко Илья Игоревич
3+Группа: БПИ 171-1
4+Дата: 5.6.18
5+Вариант: 4
6+*/
7+
8+using System;
9+using System.IO;
10+using System.Linq;
11+
12+namespace Reader {
13+ class MainClass {
14+ private static string path = "../../../nums.txt";
15+ public static void Main(string[] args) {
16+ try {
17+ var text = File.ReadAllText(path);
18+ Console.WriteLine("\tThe contents of the file:");
19+ Console.WriteLine();
20+ Console.WriteLine(text);
21+
22+ Console.WriteLine("\tElements as they are in file:");
23+ Console.WriteLine();
24+
25+ var processing = new Processing(path);
26+ foreach (var d in processing) {
27+ Console.WriteLine(d);
28+ Console.WriteLine();
29+ }
30+
31+ Console.WriteLine();
32+
33+ var sorted = from d in processing
34+ orderby d.D / d.M ascending
35+ select d;
36+ Console.WriteLine("\tSorted elements:");
37+ Console.WriteLine();
38+
39+ foreach (var d in sorted) {
40+ Console.WriteLine(d);
41+ Console.WriteLine();
42+ }
43+ } catch {
44+ Console.WriteLine("\tThere was an error reading the file.");
45+ return;
46+ }
47+
48+ }
49+ }
50+}
Reader/Properties/AssemblyInfo.csnew file+26
@@ -0,0 +1,26 @@
1+using System.Reflection;
2+using System.Runtime.CompilerServices;
3+
4+// Information about this assembly is defined by the following attributes.
5+// Change them to the values specific to your project.
6+
7+[assembly: AssemblyTitle("Reader")]
8+[assembly: AssemblyDescription("")]
9+[assembly: AssemblyConfiguration("")]
10+[assembly: AssemblyCompany("")]
11+[assembly: AssemblyProduct("")]
12+[assembly: AssemblyCopyright("")]
13+[assembly: AssemblyTrademark("")]
14+[assembly: AssemblyCulture("")]
15+
16+// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
17+// The form "{Major}.{Minor}.*" will automatically update the build and revision,
18+// and "{Major}.{Minor}.{Build}.*" will update just the revision.
19+
20+[assembly: AssemblyVersion("1.0.*")]
21+
22+// The following attributes are used to specify the signing key for the assembly,
23+// if desired. See the Mono documentation for more information about signing.
24+
25+//[assembly: AssemblyDelaySign(false)]
26+//[assembly: AssemblyKeyFile("")]
Reader/Reader.csprojnew file+41
@@ -0,0 +1,41 @@
1+<?xml version="1.0" encoding="utf-8"?>
2+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+ <PropertyGroup>
4+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
5+ <Platform Condition=" '$(Platform)' == '' ">x86</Platform>
6+ <ProjectGuid>{4B81E1C1-3FE2-44DD-8E70-C59330524D1A}</ProjectGuid>
7+ <OutputType>Exe</OutputType>
8+ <RootNamespace>Reader</RootNamespace>
9+ <AssemblyName>Reader</AssemblyName>
10+ <TargetFrameworkVersion>v4.7</TargetFrameworkVersion>
11+ </PropertyGroup>
12+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
13+ <DebugSymbols>true</DebugSymbols>
14+ <DebugType>full</DebugType>
15+ <Optimize>false</Optimize>
16+ <OutputPath>bin\Debug</OutputPath>
17+ <DefineConstants>DEBUG;</DefineConstants>
18+ <ErrorReport>prompt</ErrorReport>
19+ <WarningLevel>4</WarningLevel>
20+ <ExternalConsole>true</ExternalConsole>
21+ <PlatformTarget>x86</PlatformTarget>
22+ </PropertyGroup>
23+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
24+ <Optimize>true</Optimize>
25+ <OutputPath>bin\Release</OutputPath>
26+ <ErrorReport>prompt</ErrorReport>
27+ <WarningLevel>4</WarningLevel>
28+ <ExternalConsole>true</ExternalConsole>
29+ <PlatformTarget>x86</PlatformTarget>
30+ </PropertyGroup>
31+ <ItemGroup>
32+ <Reference Include="System" />
33+ </ItemGroup>
34+ <ItemGroup>
35+ <Compile Include="Program.cs" />
36+ <Compile Include="Properties\AssemblyInfo.cs" />
37+ <Compile Include="Data.cs" />
38+ <Compile Include="Processing.cs" />
39+ </ItemGroup>
40+ <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
41+</Project>
Reader/bin/Debug/Reader.exenew file

Binary file not shown.

Reader/bin/Debug/Reader.pdbnew file

Binary file not shown.

Reader/obj/x86/Debug/Reader.csproj.CoreCompileInputs.cachenew file+1
@@ -0,0 +1 @@
1+81a7834e582ece0b9c9dd98a4e8f5ba3e4a7c75e
Reader/obj/x86/Debug/Reader.csproj.FileListAbsolute.txtnew file+5
@@ -0,0 +1,5 @@
1+/Users/ilya/Developer/HSE/Костюченко_4/KR4/Reader/bin/Debug/Reader.exe
2+/Users/ilya/Developer/HSE/Костюченко_4/KR4/Reader/bin/Debug/Reader.pdb
3+/Users/ilya/Developer/HSE/Костюченко_4/KR4/Reader/obj/x86/Debug/Reader.csproj.CoreCompileInputs.cache
4+/Users/ilya/Developer/HSE/Костюченко_4/KR4/Reader/obj/x86/Debug/Reader.exe
5+/Users/ilya/Developer/HSE/Костюченко_4/KR4/Reader/obj/x86/Debug/Reader.pdb
Reader/obj/x86/Debug/Reader.exenew file

Binary file not shown.

Reader/obj/x86/Debug/Reader.pdbnew file

Binary file not shown.

Writer/Program.csnew file+35
@@ -0,0 +1,35 @@
1+/*
2+ФИО: Костюченко Илья Игоревич
3+Группа: БПИ 171-1
4+Дата: 5.6.18
5+Вариант: 4
6+*/
7+
8+using System;
9+using static Iko.Iko;
10+using System.IO;
11+using System.Collections.Generic;
12+using System.Linq;
13+
14+namespace Writer {
15+ class Writer {
16+ private static Random rand = new Random();
17+
18+ public static void Main() {
19+ var k = GetInt("K = ", (n) => n > 0, "That is not a valid int bigger than 0.");
20+ var f = GetInt("F = ", (n) => n > 0, "That is not a valid int bigger than 0.");
21+ var s = GetInt("S = ", (n) => n > 0, "That is not a valid int bigger than 0.");
22+ var fs = new StreamWriter("../../../nums.txt", false);
23+ for (var i = 0; i < s; i++) {
24+ var l = rand.Next(k)+1;
25+ var ns = new List<int>();
26+ for (var j = 0; j < l; j++) {
27+ ns.Add(rand.Next(f)+1);
28+ }
29+ var line = string.Join(" ", ns.Select((n) => $"{n}"));
30+ fs.WriteLine(line);
31+ }
32+ fs.Close();
33+ }
34+ }
35+}
Writer/Properties/AssemblyInfo.csnew file+26
@@ -0,0 +1,26 @@
1+using System.Reflection;
2+using System.Runtime.CompilerServices;
3+
4+// Information about this assembly is defined by the following attributes.
5+// Change them to the values specific to your project.
6+
7+[assembly: AssemblyTitle("Writer")]
8+[assembly: AssemblyDescription("")]
9+[assembly: AssemblyConfiguration("")]
10+[assembly: AssemblyCompany("")]
11+[assembly: AssemblyProduct("")]
12+[assembly: AssemblyCopyright("")]
13+[assembly: AssemblyTrademark("")]
14+[assembly: AssemblyCulture("")]
15+
16+// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
17+// The form "{Major}.{Minor}.*" will automatically update the build and revision,
18+// and "{Major}.{Minor}.{Build}.*" will update just the revision.
19+
20+[assembly: AssemblyVersion("1.0.*")]
21+
22+// The following attributes are used to specify the signing key for the assembly,
23+// if desired. See the Mono documentation for more information about signing.
24+
25+//[assembly: AssemblyDelaySign(false)]
26+//[assembly: AssemblyKeyFile("")]
Writer/Writer.csprojnew file+40
@@ -0,0 +1,40 @@
1+<?xml version="1.0" encoding="utf-8"?>
2+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+ <PropertyGroup>
4+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
5+ <Platform Condition=" '$(Platform)' == '' ">x86</Platform>
6+ <ProjectGuid>{6CBB709C-A8D4-4CE8-ADD0-BD64CA80DAD3}</ProjectGuid>
7+ <OutputType>Exe</OutputType>
8+ <RootNamespace>Writer</RootNamespace>
9+ <AssemblyName>Writer</AssemblyName>
10+ <TargetFrameworkVersion>v4.7</TargetFrameworkVersion>
11+ </PropertyGroup>
12+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
13+ <DebugSymbols>true</DebugSymbols>
14+ <DebugType>full</DebugType>
15+ <Optimize>false</Optimize>
16+ <OutputPath>bin\Debug</OutputPath>
17+ <DefineConstants>DEBUG;</DefineConstants>
18+ <ErrorReport>prompt</ErrorReport>
19+ <WarningLevel>4</WarningLevel>
20+ <ExternalConsole>true</ExternalConsole>
21+ <PlatformTarget>x86</PlatformTarget>
22+ </PropertyGroup>
23+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
24+ <Optimize>true</Optimize>
25+ <OutputPath>bin\Release</OutputPath>
26+ <ErrorReport>prompt</ErrorReport>
27+ <WarningLevel>4</WarningLevel>
28+ <ExternalConsole>true</ExternalConsole>
29+ <PlatformTarget>x86</PlatformTarget>
30+ </PropertyGroup>
31+ <ItemGroup>
32+ <Reference Include="System" />
33+ </ItemGroup>
34+ <ItemGroup>
35+ <Compile Include="Program.cs" />
36+ <Compile Include="Properties\AssemblyInfo.cs" />
37+ <Compile Include="iko.cs" />
38+ </ItemGroup>
39+ <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
40+</Project>
Writer/bin/Debug/Writer.exenew file

Binary file not shown.

Writer/bin/Debug/Writer.pdbnew file

Binary file not shown.

Writer/iko.csnew file+107
@@ -0,0 +1,107 @@
1+using System;
2+using static System.Console;
3+
4+namespace Iko {
5+ static class Iko {
6+ /// <summary>
7+ /// Gets a double value from the user.
8+ /// </summary>
9+ /// <returns>The double.</returns>
10+ /// <param name="text">Prompt</param>
11+ /// <param name="validate">A validation function</param>
12+ /// <param name="falseText">Text to print if user fails</param>
13+ public static double GetDouble(string text, Func<double, bool> validate, string falseText) {
14+ Write(text);
15+ double res;
16+ while (true) {
17+ if (double.TryParse(ReadLine(), out res) && validate(res)) {
18+ return res;
19+ } else {
20+ WriteLine(falseText);
21+ Write(text);
22+ }
23+ }
24+ }
25+
26+ /// <summary>
27+ /// Gets a double value from the user.
28+ /// </summary>
29+ /// <returns>The double.</returns>
30+ /// <param name="text">Prompt</param>
31+ /// <param name="falseText">Text to print if user fails</param>
32+ public static double GetDouble(string text, string falseText) {
33+ return GetDouble(text, _ => { return true; }, falseText);
34+ }
35+
36+ /// <summary>
37+ /// Gets a float value from the user.
38+ /// </summary>
39+ /// <returns>The double.</returns>
40+ /// <param name="text">Prompt</param>
41+ /// <param name="validate">A validation function</param>
42+ /// <param name="falseText">Text to print if user fails</param>
43+ public static float GetFloat(string text, Func<float, bool> validate, string falseText) {
44+ Write(text);
45+ float res;
46+ while (true) {
47+ if (float.TryParse(ReadLine(), out res) && validate(res)) {
48+ return res;
49+ } else {
50+ WriteLine(falseText);
51+ Write(text);
52+ }
53+ }
54+ }
55+
56+ /// <summary>
57+ /// Gets a float value from the user.
58+ /// </summary>
59+ /// <returns>The double.</returns>
60+ /// <param name="text">Prompt</param>
61+ /// <param name="falseText">Text to print if user fails</param>
62+ public static float GetFloat(string text, string falseText) {
63+ return GetFloat(text, _ => { return true; }, falseText);
64+ }
65+
66+ /// <summary>
67+ /// Gets an int value from the user.
68+ /// </summary>
69+ /// <returns>The double.</returns>
70+ /// <param name="text">Prompt</param>
71+ /// <param name="validate">A validation function</param>
72+ /// <param name="falseText">Text to print if user fails</param>
73+ public static int GetInt(string text, Func<int, bool> validate, string falseText) {
74+ Write(text);
75+ int res;
76+ while (true) {
77+ if (int.TryParse(ReadLine(), out res) && validate(res)) {
78+ return res;
79+ } else {
80+ WriteLine(falseText);
81+ Write(text);
82+ }
83+ }
84+ }
85+
86+ /// <summary>
87+ /// Gets an int value from the user.
88+ /// </summary>
89+ /// <returns>The double.</returns>
90+ /// <param name="text">Prompt</param>
91+ /// <param name="falseText">Text to print if user fails</param>
92+ public static int GetInt(string text, string falseText) {
93+ return GetInt(text, _ => { return true; }, falseText);
94+ }
95+
96+ /// <summary>
97+ /// Repeats a given function.
98+ /// </summary>
99+ /// <param name="f">the function to be repeated</param>
100+ public static void Repeat(Action f) {
101+ do {
102+ f();
103+ Write("Press Enter to repeat program. Press any other key to quit.");
104+ } while (ReadKey().Key == ConsoleKey.Enter);
105+ }
106+ }
107+}
Writer/obj/x86/Debug/Writer.csproj.CoreCompileInputs.cachenew file+1
@@ -0,0 +1 @@
1+37eefea0265591ab4b5521c5eef13e715fef2531
Writer/obj/x86/Debug/Writer.csproj.FileListAbsolute.txtnew file+5
@@ -0,0 +1,5 @@
1+/Users/ilya/Developer/HSE/Костюченко_4/KR4/Writer/obj/x86/Debug/Writer.csproj.CoreCompileInputs.cache
2+/Users/ilya/Developer/HSE/Костюченко_4/KR4/Writer/bin/Debug/Writer.exe
3+/Users/ilya/Developer/HSE/Костюченко_4/KR4/Writer/bin/Debug/Writer.pdb
4+/Users/ilya/Developer/HSE/Костюченко_4/KR4/Writer/obj/x86/Debug/Writer.exe
5+/Users/ilya/Developer/HSE/Костюченко_4/KR4/Writer/obj/x86/Debug/Writer.pdb
Writer/obj/x86/Debug/Writer.csprojResolveAssemblyReference.cachenew file

Binary file not shown.

Writer/obj/x86/Debug/Writer.exenew file

Binary file not shown.

Writer/obj/x86/Debug/Writer.pdbnew file

Binary file not shown.

nums.txtnew file+10
@@ -0,0 +1,10 @@
1+2
2+2 1 1
3+1 2 2
4+2
5+1 2
6+1 2
7+2 1 2
8+2 1
9+2 1
10+1