bastien.monsarrat 6 年之前
父節點
當前提交
bc10f16701
共有 5 個文件被更改,包括 88 次插入0 次删除
  1. 6 0
      Adv2018.sln
  2. 9 0
      D8.1/D08.1.csproj
  3. 65 0
      D8.1/Program.cs
  4. 8 0
      D8.1/Properties/launchSettings.json
  5. 0 0
      D8.1/input.txt

+ 6 - 0
Adv2018.sln

@@ -33,6 +33,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "D07.1", "D7.1\D07.1.csproj"
 EndProject
 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "D07.2", "D7.2\D07.2.csproj", "{1FFA5ACA-AB3A-4858-A92D-D741853F7A89}"
 EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "D08.1", "D8.1\D08.1.csproj", "{FF55594F-5EFF-4F7C-9882-34ED5F8E6EE0}"
+EndProject
 Global
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
 		Debug|Any CPU = Debug|Any CPU
@@ -99,6 +101,10 @@ Global
 		{1FFA5ACA-AB3A-4858-A92D-D741853F7A89}.Debug|Any CPU.Build.0 = Debug|Any CPU
 		{1FFA5ACA-AB3A-4858-A92D-D741853F7A89}.Release|Any CPU.ActiveCfg = Release|Any CPU
 		{1FFA5ACA-AB3A-4858-A92D-D741853F7A89}.Release|Any CPU.Build.0 = Release|Any CPU
+		{FF55594F-5EFF-4F7C-9882-34ED5F8E6EE0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{FF55594F-5EFF-4F7C-9882-34ED5F8E6EE0}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{FF55594F-5EFF-4F7C-9882-34ED5F8E6EE0}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{FF55594F-5EFF-4F7C-9882-34ED5F8E6EE0}.Release|Any CPU.Build.0 = Release|Any CPU
 	EndGlobalSection
 	GlobalSection(SolutionProperties) = preSolution
 		HideSolutionNode = FALSE

+ 9 - 0
D8.1/D08.1.csproj

@@ -0,0 +1,9 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+  <PropertyGroup>
+    <OutputType>Exe</OutputType>
+    <TargetFramework>netcoreapp2.1</TargetFramework>
+    <RootNamespace>D8._1</RootNamespace>
+  </PropertyGroup>
+
+</Project>

+ 65 - 0
D8.1/Program.cs

@@ -0,0 +1,65 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+
+namespace D8._1
+{
+    class Program
+    {
+        static void Main(string[] args)
+        {
+            if (args.Length < 1) return;
+            if (File.Exists(args[0]) == false) return;
+            var file = File.OpenText(args[0]);
+
+            var text = file.ReadToEnd();
+            var all = new List<string>(text.Split(" "));
+
+            int result = 0;
+            var root = getNode(all, ref result);
+
+            Console.WriteLine($"Result is : {result}");
+        }
+
+        static Node getNode(List<string> all, ref int result)
+        {
+            var node = new Node();
+
+            (int children, int metadatas) header = (int.Parse(all[0]), int.Parse(all[1]));
+
+            all.RemoveAt(0);
+            all.RemoveAt(0);
+
+            for (int j = 0; j < header.children; j++)
+            {
+                var childnode = getNode(all, ref result);
+                node.Children.Add(childnode);
+            }
+
+            for (int j = 0; j < header.metadatas; j++)
+            {
+                int meta = int.Parse(all[0]);
+                all.RemoveAt(0);
+                node.Meta.Add(meta);
+
+                result += meta;
+            }
+
+            return node;
+        }
+    }
+
+
+    class Node
+    {
+        public List<int> Meta { get; set; }
+
+        public List<Node> Children { get; set; }
+
+        public Node()
+        {
+            Meta = new List<int>();
+            Children = new List<Node>();
+        }
+    }
+}

+ 8 - 0
D8.1/Properties/launchSettings.json

@@ -0,0 +1,8 @@
+{
+  "profiles": {
+    "D08.1": {
+      "commandName": "Project",
+      "commandLineArgs": "\"D:\\adv\\Adv2018\\D8.1\\input.txt\" "
+    }
+  }
+}

文件差異過大導致無法顯示
+ 0 - 0
D8.1/input.txt


部分文件因文件數量過多而無法顯示