diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..1ff0c42 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,63 @@ +############################################################################### +# Set default behavior to automatically normalize line endings. +############################################################################### +* text=auto + +############################################################################### +# Set default behavior for command prompt diff. +# +# This is need for earlier builds of msysgit that does not have it on by +# default for csharp files. +# Note: This is only used by command line +############################################################################### +#*.cs diff=csharp + +############################################################################### +# Set the merge driver for project and solution files +# +# Merging from the command prompt will add diff markers to the files if there +# are conflicts (Merging from VS is not affected by the settings below, in VS +# the diff markers are never inserted). Diff markers may cause the following +# file extensions to fail to load in VS. An alternative would be to treat +# these files as binary and thus will always conflict and require user +# intervention with every merge. To do so, just uncomment the entries below +############################################################################### +#*.sln merge=binary +#*.csproj merge=binary +#*.vbproj merge=binary +#*.vcxproj merge=binary +#*.vcproj merge=binary +#*.dbproj merge=binary +#*.fsproj merge=binary +#*.lsproj merge=binary +#*.wixproj merge=binary +#*.modelproj merge=binary +#*.sqlproj merge=binary +#*.wwaproj merge=binary + +############################################################################### +# behavior for image files +# +# image files are treated as binary by default. +############################################################################### +#*.jpg binary +#*.png binary +#*.gif binary + +############################################################################### +# diff behavior for common document formats +# +# Convert binary document formats to text before diffing them. This feature +# is only available from the command line. Turn it on by uncommenting the +# entries below. +############################################################################### +#*.doc diff=astextplain +#*.DOC diff=astextplain +#*.docx diff=astextplain +#*.DOCX diff=astextplain +#*.dot diff=astextplain +#*.DOT diff=astextplain +#*.pdf diff=astextplain +#*.PDF diff=astextplain +#*.rtf diff=astextplain +#*.RTF diff=astextplain diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3c4efe2 --- /dev/null +++ b/.gitignore @@ -0,0 +1,261 @@ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. + +# User-specific files +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ + +# Visual Studio 2015 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUNIT +*.VisualState.xml +TestResult.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# DNX +project.lock.json +project.fragment.lock.json +artifacts/ + +*_i.c +*_p.c +*_i.h +*.ilk +*.meta +*.obj +*.pch +*.pdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# JustCode is a .NET coding add-in +.JustCode + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# TODO: Comment the next line if you want to checkin your web deploy settings +# but database connection strings (with potential passwords) will be unencrypted +#*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# The packages folder can be ignored because of Package Restore +**/packages/* +# except build/, which is used as an MSBuild target. +!**/packages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/packages/repositories.config +# NuGet v3's project.json files produces more ignoreable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +node_modules/ +orleans.codegen.cs + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm + +# SQL Server files +*.mdf +*.ldf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# JetBrains Rider +.idea/ +*.sln.iml + +# CodeRush +.cr/ + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc \ No newline at end of file diff --git a/.vs/comivoyar/v15/.suo b/.vs/comivoyar/v15/.suo index 3312db9..5b171cf 100644 Binary files a/.vs/comivoyar/v15/.suo and b/.vs/comivoyar/v15/.suo differ diff --git a/1.bmp b/1.bmp new file mode 100644 index 0000000..1fcac58 Binary files /dev/null and b/1.bmp differ diff --git a/comivoyar/Program.cs b/comivoyar/Program.cs index b7a2ffa..1236ac0 100644 --- a/comivoyar/Program.cs +++ b/comivoyar/Program.cs @@ -1,8 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using System.IO; using static System.Console; @@ -10,7 +7,7 @@ namespace komvo { class Program { - public static List Points = new List(); + public static List Points = new List(); static void Main(string[] args) { @@ -22,7 +19,7 @@ namespace komvo while ((line = cr.ReadLine()) != null) { string[] str = line.Split(); - Points.Add(new point { X = int.Parse(str[0]), Y = int.Parse(str[1]) }); + Points.Add(new Point { X = int.Parse(str[0]), Y = int.Parse(str[1]) }); } } @@ -30,7 +27,7 @@ namespace komvo double[,] Matrix = new double[matr, matr]; - foreach (point p in Points) + foreach (Point p in Points) { WriteLine("{0} {1}", p.X, p.Y); } @@ -48,46 +45,79 @@ namespace komvo } - for (int i = 0; i < 4; i++) + for (int i = 0; i < matr; i++) { - for (int j = 0; j < 4; j++) Write("{0:00.00} ", Matrix[i, j]); + for (int j = 0; j < matr; j++) Write("{0:00.00} ", Matrix[i, j]); WriteLine(); } - string formP = string.Empty, formN = string.Empty; + string formP = string.Empty; for (int i = 2; i <= Points.Count; i++) formP += i.ToString(); - for (int i = Points.Count; i >= 2; i--) formN += i.ToString(); - WriteLine("{0} {1} {2}", formP, formN, Fact(Points.Count - 1)); - WriteLine(formP + " " + Swap(formP, 1, 2)); + WriteLine("{0} {1}", formP, Fact(Points.Count - 1)); WriteLine("\n\n"); int[] routes = new int[Fact(Points.Count - 1)]; double[] leng = new double[Fact(Points.Count - 1)]; - int begin = int.Parse(formP), end = int.Parse(formN); - for (int b = begin; b <= 234; b++) + int waves = 0; + if (Points.Count == 4) waves = 1; + else if (Points.Count == 5) waves = 4; + else if (Points.Count == 6) waves = 20; + + int cn = 0, cn2 = 0; + string inf = formP; + for (int i = 1; i < waves + 1; i++) { - string number = b.ToString(); - routes[0] = int.Parse(number); - routes[1] = int.Parse(Swap(number, 1, 2)); - routes[2] = int.Parse(number = Swap(number, 0, 1)); - routes[3] = int.Parse(Swap(number, 1, 2)); - routes[4] = int.Parse(number = Swap(number, 0, 2)); - routes[5] = int.Parse(Swap(number, 1, 2)); + for(int j = 0; j < 6; j++) + { + if (i == 0 && j == 0) routes[j + (i - 1) * 6] = int.Parse(formP); + else if (j % 2 == 0) routes[j + (i - 1) * 6] = int.Parse(formP = Swap(formP, 0, j / 2)); + else routes[j + (i - 1) * 6] = int.Parse(Swap(formP, 1, 2)); + } + if (waves > 1) + { - //for (int i = 0; i < Points.Count; i++) - //{ - // for (int j = i; j < Points.Count - 1; j++) - // { + if (i % 5 == 0) + { + formP = Swap(inf, cn2++, 4); + WriteLine("{0} {1}", formP, inf); + } + else + { + if (cn > 2) cn = 0; + formP = Swap(inf, cn++, 3); + WriteLine("{0} {1}", formP, inf); + } + + + //if (cn > 4) + //{ + // cn = 0; + // formP = Swap(inf, cn2, 4); + // cn2++; + //} + //else + //{ + //formP = Swap(inf, cn, 3); + //} + //cn++; + } + + + + + //routes[0] = int.Parse(formP); + //routes[1] = int.Parse(Swap(formP, 1, 2)); + //routes[2] = int.Parse(formP = Swap(formP, 0, 1)); + //routes[3] = int.Parse(Swap(formP, 1, 2)); + //routes[4] = int.Parse(formP = Swap(formP, 0, 2)); + //routes[5] = int.Parse(Swap(formP, 1, 2)); - // } - // //WriteLine(); - //} } @@ -110,18 +140,36 @@ namespace komvo { res += Matrix[int.Parse(ch[j - 1].ToString()) - 1, int.Parse(ch[j].ToString()) - 1]; } - } leng[i] = res; } - for (int i = 0; i < leng.Length; i++) WriteLine("{0:N2}", leng[i]); + double optim = leng[0]; + int oIndex = 0; + for (int i = 0; i < leng.Length; i++) + { + WriteLine("{0:N2} - {1}", leng[i], routes[i]); + if (optim > leng[i]) + { + optim = leng[i]; + oIndex = i; + } + } + + + for (int i = 0; i < routes.Length; i++) + { + for (int j = i + 1; j < routes.Length - 1; j++) + if (routes[i].Equals(routes[j])) WriteLine("{0} {2}:: {1} {3}!!!!", routes[i], routes[j], i, j); + } + WriteLine("\n\n1{1}1 - оптимальный маршрут длинной {0:00.00}\nВсего маршрутов {2}\n{4} {3}", + optim, routes[oIndex], routes.Length, Fact(Points.Count - 1), Points.Count); - //WriteLine(routes[0]); + //WriteLine(Fact(5)); //MessageBox.Show(Math.Sqrt(-1).ToString()); ReadKey(); @@ -138,21 +186,13 @@ namespace komvo } - static public int Fact(int nm) - { - int res = 1; - for (int i = 1; i <= nm; i++) - { - res *= i; - } - return res; - } - - - public partial struct point + public partial struct Point { public int X { get; set; } public int Y { get; set; } } + + + static int Fact(int a) => a <= 1 ? 1 : a * Fact(a - 1); } } \ No newline at end of file diff --git a/comivoyar/bin/Debug/comivoyar.exe b/comivoyar/bin/Debug/comivoyar.exe index 1754b6d..78cdbba 100644 Binary files a/comivoyar/bin/Debug/comivoyar.exe and b/comivoyar/bin/Debug/comivoyar.exe differ diff --git a/comivoyar/bin/Debug/comivoyar.pdb b/comivoyar/bin/Debug/comivoyar.pdb index 4e6d5dc..066940a 100644 Binary files a/comivoyar/bin/Debug/comivoyar.pdb and b/comivoyar/bin/Debug/comivoyar.pdb differ diff --git a/comivoyar/bin/Debug/coord.txt b/comivoyar/bin/Debug/coord.txt index c23245f..e0bcba9 100644 --- a/comivoyar/bin/Debug/coord.txt +++ b/comivoyar/bin/Debug/coord.txt @@ -1,4 +1,5 @@ -30 40 -20 50 -10 23 -35 32 \ No newline at end of file +10 10 +20 20 +30 30 +40 40 +50 50 \ No newline at end of file diff --git a/comivoyar/obj/Debug/comivoyar.csproj.CoreCompileInputs.cache b/comivoyar/obj/Debug/comivoyar.csproj.CoreCompileInputs.cache index 125c6b5..e4c5453 100644 --- a/comivoyar/obj/Debug/comivoyar.csproj.CoreCompileInputs.cache +++ b/comivoyar/obj/Debug/comivoyar.csproj.CoreCompileInputs.cache @@ -1 +1 @@ -a325577e7d0bb098d5c8871f5acaa6c0c34b21c6 +6eed873852f8ce9c50ebe974dac1f20cc4ef270e diff --git a/comivoyar/obj/Debug/comivoyar.csproj.FileListAbsolute.txt b/comivoyar/obj/Debug/comivoyar.csproj.FileListAbsolute.txt index 3319c42..87e761f 100644 --- a/comivoyar/obj/Debug/comivoyar.csproj.FileListAbsolute.txt +++ b/comivoyar/obj/Debug/comivoyar.csproj.FileListAbsolute.txt @@ -5,3 +5,10 @@ E:\кк\прог\comivoyar\comivoyar\obj\Debug\comivoyar.csprojAssemblyReference E:\кк\прог\comivoyar\comivoyar\obj\Debug\comivoyar.csproj.CoreCompileInputs.cache E:\кк\прог\comivoyar\comivoyar\obj\Debug\comivoyar.exe E:\кк\прог\comivoyar\comivoyar\obj\Debug\comivoyar.pdb +D:\Git\comvo\comivoyar\bin\Debug\comivoyar.exe.config +D:\Git\comvo\comivoyar\bin\Debug\comivoyar.exe +D:\Git\comvo\comivoyar\bin\Debug\comivoyar.pdb +D:\Git\comvo\comivoyar\obj\Debug\comivoyar.csprojAssemblyReference.cache +D:\Git\comvo\comivoyar\obj\Debug\comivoyar.csproj.CoreCompileInputs.cache +D:\Git\comvo\comivoyar\obj\Debug\comivoyar.exe +D:\Git\comvo\comivoyar\obj\Debug\comivoyar.pdb diff --git a/comivoyar/obj/Debug/comivoyar.exe b/comivoyar/obj/Debug/comivoyar.exe index 1754b6d..78cdbba 100644 Binary files a/comivoyar/obj/Debug/comivoyar.exe and b/comivoyar/obj/Debug/comivoyar.exe differ diff --git a/comivoyar/obj/Debug/comivoyar.pdb b/comivoyar/obj/Debug/comivoyar.pdb index 4e6d5dc..066940a 100644 Binary files a/comivoyar/obj/Debug/comivoyar.pdb and b/comivoyar/obj/Debug/comivoyar.pdb differ