diff --git a/201731062616/ConsoleApp2/.vs/ConsoleApp2/v15/.suo b/201731062616/ConsoleApp2/.vs/ConsoleApp2/v15/.suo new file mode 100644 index 0000000..2715ebb Binary files /dev/null and b/201731062616/ConsoleApp2/.vs/ConsoleApp2/v15/.suo differ diff --git a/201731062616/ConsoleApp2/.vs/ConsoleApp2/v15/Server/sqlite3/db.lock b/201731062616/ConsoleApp2/.vs/ConsoleApp2/v15/Server/sqlite3/db.lock new file mode 100644 index 0000000..e69de29 diff --git a/201731062616/ConsoleApp2/.vs/ConsoleApp2/v15/Server/sqlite3/storage.ide b/201731062616/ConsoleApp2/.vs/ConsoleApp2/v15/Server/sqlite3/storage.ide new file mode 100644 index 0000000..56758a8 Binary files /dev/null and b/201731062616/ConsoleApp2/.vs/ConsoleApp2/v15/Server/sqlite3/storage.ide differ diff --git a/201731062616/ConsoleApp2/.vs/ConsoleApp2/v15/Server/sqlite3/storage.ide-shm b/201731062616/ConsoleApp2/.vs/ConsoleApp2/v15/Server/sqlite3/storage.ide-shm new file mode 100644 index 0000000..6127827 Binary files /dev/null and b/201731062616/ConsoleApp2/.vs/ConsoleApp2/v15/Server/sqlite3/storage.ide-shm differ diff --git a/201731062616/ConsoleApp2/.vs/ConsoleApp2/v15/Server/sqlite3/storage.ide-wal b/201731062616/ConsoleApp2/.vs/ConsoleApp2/v15/Server/sqlite3/storage.ide-wal new file mode 100644 index 0000000..971a08e Binary files /dev/null and b/201731062616/ConsoleApp2/.vs/ConsoleApp2/v15/Server/sqlite3/storage.ide-wal differ diff --git a/201731062616/ConsoleApp2/ConsoleApp2.sln b/201731062616/ConsoleApp2/ConsoleApp2.sln new file mode 100644 index 0000000..8cf624a --- /dev/null +++ b/201731062616/ConsoleApp2/ConsoleApp2.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.28307.438 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleApp2", "ConsoleApp2\ConsoleApp2.csproj", "{91A0E9F3-0CE3-4C7C-AF6A-EE93D64DBD86}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {91A0E9F3-0CE3-4C7C-AF6A-EE93D64DBD86}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {91A0E9F3-0CE3-4C7C-AF6A-EE93D64DBD86}.Debug|Any CPU.Build.0 = Debug|Any CPU + {91A0E9F3-0CE3-4C7C-AF6A-EE93D64DBD86}.Release|Any CPU.ActiveCfg = Release|Any CPU + {91A0E9F3-0CE3-4C7C-AF6A-EE93D64DBD86}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {FC92EE05-1912-4B9D-BF7B-B5DFE2B0D7CC} + EndGlobalSection +EndGlobal diff --git a/201731062616/ConsoleApp2/ConsoleApp2/App.config b/201731062616/ConsoleApp2/ConsoleApp2/App.config new file mode 100644 index 0000000..731f6de --- /dev/null +++ b/201731062616/ConsoleApp2/ConsoleApp2/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/201731062616/ConsoleApp2/ConsoleApp2/ConsoleApp2.csproj b/201731062616/ConsoleApp2/ConsoleApp2/ConsoleApp2.csproj new file mode 100644 index 0000000..bbbebcc --- /dev/null +++ b/201731062616/ConsoleApp2/ConsoleApp2/ConsoleApp2.csproj @@ -0,0 +1,53 @@ + + + + + Debug + AnyCPU + {91A0E9F3-0CE3-4C7C-AF6A-EE93D64DBD86} + Exe + ConsoleApp2 + ConsoleApp2 + v4.6.1 + 512 + true + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/201731062616/ConsoleApp2/ConsoleApp2/Program.cs b/201731062616/ConsoleApp2/ConsoleApp2/Program.cs new file mode 100644 index 0000000..e056898 --- /dev/null +++ b/201731062616/ConsoleApp2/ConsoleApp2/Program.cs @@ -0,0 +1,148 @@ +using System; +using System.IO; +using System.Text.RegularExpressions; +using System.Collections.Generic; + +namespace ConsoleApp52 +{ + class zifu//统计字符数 + { + public void A(string path) + { + int charcount = 0; + int nchar; + StreamReader sr = new StreamReader(path); + char[] symbol = { ' ', '\t', ',', '.', '?', '!', ':', ';', '\'', '\"', '\n', '{', '}', '(', ')', '+' ,'-', + '*', '='}; + while ((nchar = sr.Read()) != -1) + { + charcount++; + } + Console.WriteLine("characters :{0}", charcount); + + } + + } + class word//统计字母数大于4的单词 + { + int wordcount = 0; + public void B(string path) + { + string pattren = @"\s+|,\s*"; + StreamReader sr = new StreamReader(path); + string line = sr.ReadToEnd(); + Regex myregex = new Regex(pattren); + string[] output = myregex.Split(line); + foreach (string s in output) + { + if (s.Length > 3) + wordcount++; + } + Console.WriteLine("words :{0}", wordcount); + + } + + } + class line//统计行数 + { + + public void C(string path) + { + int linecount = 0; + string nchar; + StreamReader sr = new StreamReader(path); + while ((nchar = sr.ReadLine()) != null) + { + + linecount++; + + } + Console.WriteLine("line :{0}", linecount); + + } + + } + class Program + { + static void Main(string[] args) + { + string path = @"D:\git\WordCount\201731062616\ConsoleApp2\ConsoleApp2\bin\Debug\第三次作业.txt"; + List listnew = new List();//所有单词放在listnew中 + string pattren = @"\s+|,\s*"; + StreamReader sr = new StreamReader(path); + string line = sr.ReadToEnd(); + Regex myregex = new Regex(pattren); + string[] output = myregex.Split(line); + foreach (string s in output) + { + if (s.Length > 3) + listnew.Add(s); + } + + zifu a = new zifu(); + word b = new word(); + line c = new line(); + a.A(path); + b.B(path); + c.C(path); + + Dictionary keyValuePairs = new Dictionary(); + foreach (var word in listnew) + { + if (keyValuePairs.ContainsKey(word)) + { + keyValuePairs[word]++; + } + else + { + keyValuePairs.Add(word, 1); + } + } + List value = new List(); + foreach (var s in keyValuePairs.Values) + { + value.Add(s); + } + value.Sort((x, y) => -x.CompareTo(y)); + int count = 0; + // Console.Write("频率:" + value[0] + " "); + foreach (var s in keyValuePairs) + { + if (s.Value.Equals(value[0])) + { + Console.WriteLine(s.Key + ":" + value[0]); + count++; + } + } + + for (int i = 1; i < value.Count; i++) + { + if (count != 10) + { + if (value[i] == value[i - 1]) + continue; + foreach (var s in keyValuePairs) + { + if (s.Value.Equals(value[i])) + { + if (count != 10) + { + Console.WriteLine(s.Key + ":" + value[i]); + count++; + } + else + break; + } + } + } + else + break; + + } + + + + + } + } +} \ No newline at end of file diff --git a/201731062616/ConsoleApp2/ConsoleApp2/Properties/AssemblyInfo.cs b/201731062616/ConsoleApp2/ConsoleApp2/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..8886245 --- /dev/null +++ b/201731062616/ConsoleApp2/ConsoleApp2/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// 有关程序集的一般信息由以下 +// 控制。更改这些特性值可修改 +// 与程序集关联的信息。 +[assembly: AssemblyTitle("ConsoleApp2")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("HP Inc.")] +[assembly: AssemblyProduct("ConsoleApp2")] +[assembly: AssemblyCopyright("Copyright © HP Inc. 2019")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// 将 ComVisible 设置为 false 会使此程序集中的类型 +//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型 +//请将此类型的 ComVisible 特性设置为 true。 +[assembly: ComVisible(false)] + +// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID +[assembly: Guid("91a0e9f3-0ce3-4c7c-af6a-ee93d64dbd86")] + +// 程序集的版本信息由下列四个值组成: +// +// 主版本 +// 次版本 +// 生成号 +// 修订号 +// +// 可以指定所有值,也可以使用以下所示的 "*" 预置版本号和修订号 +// 方法是按如下所示使用“*”: : +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/201731062616/ConsoleApp2/ConsoleApp2/bin/Debug/ConsoleApp2.exe b/201731062616/ConsoleApp2/ConsoleApp2/bin/Debug/ConsoleApp2.exe new file mode 100644 index 0000000..7a3c082 Binary files /dev/null and b/201731062616/ConsoleApp2/ConsoleApp2/bin/Debug/ConsoleApp2.exe differ diff --git a/201731062616/ConsoleApp2/ConsoleApp2/bin/Debug/ConsoleApp2.exe.config b/201731062616/ConsoleApp2/ConsoleApp2/bin/Debug/ConsoleApp2.exe.config new file mode 100644 index 0000000..731f6de --- /dev/null +++ b/201731062616/ConsoleApp2/ConsoleApp2/bin/Debug/ConsoleApp2.exe.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/201731062616/ConsoleApp2/ConsoleApp2/bin/Debug/ConsoleApp2.pdb b/201731062616/ConsoleApp2/ConsoleApp2/bin/Debug/ConsoleApp2.pdb new file mode 100644 index 0000000..c829217 Binary files /dev/null and b/201731062616/ConsoleApp2/ConsoleApp2/bin/Debug/ConsoleApp2.pdb differ diff --git "a/201731062616/ConsoleApp2/ConsoleApp2/bin/Debug/\347\254\254\344\270\211\346\254\241\344\275\234\344\270\232.txt" "b/201731062616/ConsoleApp2/ConsoleApp2/bin/Debug/\347\254\254\344\270\211\346\254\241\344\275\234\344\270\232.txt" new file mode 100644 index 0000000..3562700 --- /dev/null +++ "b/201731062616/ConsoleApp2/ConsoleApp2/bin/Debug/\347\254\254\344\270\211\346\254\241\344\275\234\344\270\232.txt" @@ -0,0 +1,13 @@ +We all know that environment is so important to ourselves and our future generations. Natural resources have been depleted in an unprecedented scale. The environment ha +s been polluted in a way that never happened before. It is certain that the world and all the living organism on it are going straight to hell. But why those in power, + no matter how loud they speak out environmental protection, very few of them really care. The reason is simple. Human beings are greedy in nature. In ancient times, te +chnology is lacking, human beings did not have the right tool to exploit the nature on large scale. With industrial revolution and the development of science and techno +logy, these things can be achieved with relative ease. It can be said that the development of science can be a gospel and a curse on human race at the same time. It is +more than certain that the world is going straight to hell. Climate change comes at an unprecedented rate. We can see all the polar ice sheet melt in our own lifetime. +Cities by the sea will be flooded. Summer will get unbearably hot. Almost all the natural resources will be depleted. It is not that world leaders are unaware of this , + but because of their greed no one is able to put the interest of the general public and future generations over their own pride. Development sounds an untouchable trut +h. Anything that comes in its way will be neglected. One thing that we never ponder is that the space and resources on this planet is limited which means that the raw +material and space for development is also limited. Now matter how great and intelligent human beings might be, we have our own weakness. The more intelligent a +creature is, the more physically vulnerable it is. With the worsening of the living environment, one can rarely predict that how many of us will eventually survive +this unprecedented change. It is time for us to think whether we should live in a more environmentally friendly manner so that our offsprings will also have space and +resources to live with or we just pamper ourselves to the extreme and forget about our future generation and the human race at large. \ No newline at end of file diff --git a/201731062616/ConsoleApp2/ConsoleApp2/obj/Debug/ConsoleApp2.csproj.CoreCompileInputs.cache b/201731062616/ConsoleApp2/ConsoleApp2/obj/Debug/ConsoleApp2.csproj.CoreCompileInputs.cache new file mode 100644 index 0000000..d1fb0aa --- /dev/null +++ b/201731062616/ConsoleApp2/ConsoleApp2/obj/Debug/ConsoleApp2.csproj.CoreCompileInputs.cache @@ -0,0 +1 @@ +eb377b6b14e4ef154eb9357e15b38cc4e484fff8 diff --git a/201731062616/ConsoleApp2/ConsoleApp2/obj/Debug/ConsoleApp2.csproj.FileListAbsolute.txt b/201731062616/ConsoleApp2/ConsoleApp2/obj/Debug/ConsoleApp2.csproj.FileListAbsolute.txt new file mode 100644 index 0000000..120551a --- /dev/null +++ b/201731062616/ConsoleApp2/ConsoleApp2/obj/Debug/ConsoleApp2.csproj.FileListAbsolute.txt @@ -0,0 +1,7 @@ +D:\git\WordCount\201731062616\ConsoleApp2\ConsoleApp2\bin\Debug\ConsoleApp2.exe.config +D:\git\WordCount\201731062616\ConsoleApp2\ConsoleApp2\bin\Debug\ConsoleApp2.exe +D:\git\WordCount\201731062616\ConsoleApp2\ConsoleApp2\bin\Debug\ConsoleApp2.pdb +D:\git\WordCount\201731062616\ConsoleApp2\ConsoleApp2\obj\Debug\ConsoleApp2.csprojAssemblyReference.cache +D:\git\WordCount\201731062616\ConsoleApp2\ConsoleApp2\obj\Debug\ConsoleApp2.csproj.CoreCompileInputs.cache +D:\git\WordCount\201731062616\ConsoleApp2\ConsoleApp2\obj\Debug\ConsoleApp2.exe +D:\git\WordCount\201731062616\ConsoleApp2\ConsoleApp2\obj\Debug\ConsoleApp2.pdb diff --git a/201731062616/ConsoleApp2/ConsoleApp2/obj/Debug/ConsoleApp2.csprojAssemblyReference.cache b/201731062616/ConsoleApp2/ConsoleApp2/obj/Debug/ConsoleApp2.csprojAssemblyReference.cache new file mode 100644 index 0000000..d31b6fe Binary files /dev/null and b/201731062616/ConsoleApp2/ConsoleApp2/obj/Debug/ConsoleApp2.csprojAssemblyReference.cache differ diff --git a/201731062616/ConsoleApp2/ConsoleApp2/obj/Debug/ConsoleApp2.exe b/201731062616/ConsoleApp2/ConsoleApp2/obj/Debug/ConsoleApp2.exe new file mode 100644 index 0000000..7a3c082 Binary files /dev/null and b/201731062616/ConsoleApp2/ConsoleApp2/obj/Debug/ConsoleApp2.exe differ diff --git a/201731062616/ConsoleApp2/ConsoleApp2/obj/Debug/ConsoleApp2.pdb b/201731062616/ConsoleApp2/ConsoleApp2/obj/Debug/ConsoleApp2.pdb new file mode 100644 index 0000000..c829217 Binary files /dev/null and b/201731062616/ConsoleApp2/ConsoleApp2/obj/Debug/ConsoleApp2.pdb differ diff --git a/201731062616/ConsoleApp2/ConsoleApp2/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache b/201731062616/ConsoleApp2/ConsoleApp2/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache new file mode 100644 index 0000000..d3a532d Binary files /dev/null and b/201731062616/ConsoleApp2/ConsoleApp2/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache differ diff --git a/201731062616/ConsoleApp2/ConsoleApp2/obj/Debug/TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs b/201731062616/ConsoleApp2/ConsoleApp2/obj/Debug/TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs new file mode 100644 index 0000000..e69de29 diff --git a/201731062616/ConsoleApp2/ConsoleApp2/obj/Debug/TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs b/201731062616/ConsoleApp2/ConsoleApp2/obj/Debug/TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs new file mode 100644 index 0000000..e69de29 diff --git a/201731062616/ConsoleApp2/ConsoleApp2/obj/Debug/TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs b/201731062616/ConsoleApp2/ConsoleApp2/obj/Debug/TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs new file mode 100644 index 0000000..e69de29