[C#] 大数相乘 →→→→→进入此内容的聊天室

来自 , 2019-08-27, 写在 C#, 查看 134 次.
URL http://www.code666.cn/view/92426b26
  1. using System;
  2.  
  3. namespace demo4
  4. {
  5.         class Bignum
  6.         {
  7.                 public static void Main(string[] args)
  8.                 {
  9.                         Console.WriteLine("请输入一个乘数:");
  10.                         uint x = uint.Parse(Console.ReadLine());
  11.                         Console.WriteLine("请输入另一个乘数:");
  12.                         uint y = uint.Parse(Console.ReadLine());
  13.  
  14.                         ulong z = 0;
  15.                         //uint 为32位整数
  16.                         for(int i = 0; i<32; i++)
  17.                         {
  18.                                 if(y % 2 == 1)
  19.                                 z += x;
  20.                                 x <<= 1;
  21.                                 y >>= 1;
  22.                         }
  23.                         Console.WriteLine("The result is :{0}",z);
  24.                 }
  25.         }
  26. }

回复 "大数相乘"

这儿你可以回复上面这条便签

captcha