日本无码中文字幕片|日本精品在线观看无码视频|国产精品免费啪啪|Av无码一区二区|亚洲在线黄片免费观看|亚洲日韩中文字幕在线观看|熟女激情乱伦在线观看a黄片|成年人观看毛片网址|AV色色色色日韩性草|国产高清无码免费

KMP算法的C#實現方法

時間:2025-12-15 20:28:43 C語言

KMP算法的C#實現方法

  如何運用KMP算法實現C#呢?下面小編為大家整理了KMP算法的C#實現方法,希望能幫到大家!

  C#實現大數字的運算

  1、添加引用:System.Numerics.dll

  2、添加命名空間:using System.Numerics;

  3、實例:

  3.1判斷一個數字是不是質數

  復制代碼 代碼如下:

  static void Main(string[] args)

  {

  Console.WriteLine("請輸入一個很大的數字:");

  string bigNumber = Console.ReadLine();

  BigInteger bigInteger = BigInteger.Parse(bigNumber);

  bool isNumber=false;

  for (BigInteger i = 2; i < BigInteger.Pow(bigInteger, 2);i++ )

  {

  if (bigInteger % i == 0)

  {

  isNumber = true;

  break;

  }

  }

  if (isNumber)

  {

  Console.WriteLine("不是質數");

  }

  else

  {

  Console.WriteLine("是質數");

  }

  Console.ReadLine();

  }

  3.2實現兩個大數的加減乘除

  復制代碼 代碼如下:

  static void Main(string[] args)

  {

  Console.Write("請輸入第一個大數字:");

  string bigNum1 = Console.ReadLine();

  BigInteger bigInt1 = BigInteger.Parse(bigNum1);

  Console.Write("請輸入第二個大數字:");

  string bigNum2 = Console.ReadLine();

  BigInteger bigInt2 = BigInteger.Parse(bigNum2);

  Console.Write(Environment.NewLine);

  BigInteger addNum = bigInt1 + bigInt2;

  BigInteger subNum = bigInt1 - bigInt2;

  BigInteger purNum = bigInt1 * bigInt2;

  BigInteger divNum = bigInt1 / bigInt2;

  Console.WriteLine("兩大數相加結果為:{0}",addNum);

  Console.WriteLine("兩大數相減結果為:{0}",subNum);

  Console.WriteLine("兩大數相乘結果為:{0}",purNum);

  Console.WriteLine("兩大數相除結果為:{0}",divNum);

  Console.ReadLine();

  }

【KMP算法的C#實現方法】相關文章:

C語言中實現KMP算法實例11-16

c#實現sunday算法實例10-12

c#實現輪詢算法實例代碼10-01

快速排序算法及C#版的實現示例12-06

C#實現協(xié)同過濾算法的實例代碼10-01

c#冒泡排序算法02-03

c#快速排序算法11-16

C#抽象工廠模式的幾種實現方法及比較03-22

java算法實現排列組合的方法介紹03-08