未语愁眸

从事TAF,C++,tensorflow,caffe等深度学习框架设计开发数年。。。

我的印度软件老师,给的 几个C# PROGRAMS (2)

using System;
using System.Text.RegularExpressions;

namespace Wrox.ProCSharp.RegularExpressionPlayaround
{
   class MainEntryPoint
   {
      static void Main()
      {
         Find1();
         Console.ReadLine();
      }

      static void Find1()
      {
         string text = @"XML has made a major impact in almost every aspect of
            software development. Designed as an open, extensible, self-describing
            language, it has become the standard for data and document delivery on
            the web. The panoply of XML-related technologies continues to develop
            at breakneck speed, to enable validation, navigation, transformation,
            linking, querying, description, and messaging of data.";
         string pattern = @"/bn/S*ion/b";
         MatchCollection matches = Regex.Matches(text, pattern,
            RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace |
            RegexOptions.ExplicitCapture);
         WriteMatches(text, matches);
      }  

      static void Find2()
      {
         string text = @"XML has made a major impact in almost every aspect of
            software development. Designed as an open, extensible, self-describing
            language, it has become the standard for data and document delivery on
            the web. The panoply of XML-related technologies continues to develop
            at breakneck speed, to enable validation, navigation, transformation,
            linking, querying, description, and messaging of data.";
         string pattern = @"/bn";
         MatchCollection matches = Regex.Matches(text, pattern,
           RegexOptions.IgnoreCase);
         WriteMatches(text, matches);
      }

      static void WriteMatches(string text, MatchCollection matches)
      {
         Console.WriteLine("Original text was: /n/n" + text + "/n");
         Console.WriteLine("No. of matches: " + matches.Count);
         foreach (Match nextMatch in matches)
         {
            int Index = nextMatch.Index;
            string result = nextMatch.ToString();
            int charsBefore = (Index < 5) ? Index : 5;
            int fromEnd = text.Length - Index - result.Length;
            int charsAfter = (fromEnd < 5) ? fromEnd : 5;
            int charsToDisplay = charsBefore + charsAfter + result.Length;

            Console.WriteLine("Index: {0}, /tString: {1}, /t{2}",
               Index, result,
               text.Substring(Index - charsBefore, charsToDisplay));

         }
      }
   }
}

using System;
using System.Text;

namespace Wrox.ProCSharp.StringEncoder
{
   class MainEntryPoint
   {
      static void Main(string[] args)
      {
         string greetingText = "Hello from all the guys at Wrox Press. ";
         greetingText += "We do hope you enjoy this book as much as we enjoyed writing it.";

         for(int i = (int)'z'; i>=(int)'a' ; i--)
         {
            char Old = (char)i;
            char New = (char)(i+1);
            greetingText = greetingText.Replace(Old, New);
         }

         for(int i = (int)'Z'; i>=(int)'A' ; i--)
         {
            char Old = (char)i;
            char New = (char)(i+1);
            greetingText = greetingText.Replace(Old, New);
         }
         Console.WriteLine("Encoded:/n" + greetingText);

         StringBuilder greetingBuilder =
            new StringBuilder("Hello from all the guys at Wrox Press. ", 150);
         greetingBuilder.Append("We do hope you enjoy this book as much as we enjoyed writing it");

         for(int i = (int)'z'; i>=(int)'a' ; i--)
         {
            char Old = (char)i;
            char New = (char)(i+1);
            greetingBuilder = greetingBuilder.Replace(Old, New);
         }

         for(int i = (int)'Z'; i>=(int)'A' ; i--)
         {
            char Old = (char)i;
            char New = (char)(i+1);
            greetingBuilder = greetingBuilder.Replace(Old, New);
         }
         Console.WriteLine("Encoded:/n" + greetingBuilder.ToString());
     
      }
   }
}

阅读更多
版权声明:tensorflow caffe tars群【469331966】 ; 本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/chary8088/article/details/375183
上一篇我的印度软件老师,给的 几个C# PROGRAMS
下一篇VC++中播放声音的方法
想对作者说点什么? 我来说一句

C# 设计 模式Programs

2008年11月22日 1.29MB 下载

Matlab programs

2009年04月14日 1014B 下载

没有更多推荐了,返回首页

关闭
关闭