一个笔试题,大家看看

renjuwht 2010-01-27 12:55:26
一台计算只能处理16位无符号整数运算
如果现在想计算 9999999999999999999999999999*99999999999999999999999999
这样超大数的计算,怎么办?
...全文
325 34 打赏 收藏 转发到动态 举报
写回复
用AI写文章
34 条回复
切换为时间正序
请发表友善的回复…
发表回复
mingcsharp 2010-01-29
  • 打赏
  • 举报
回复
学习
jiangjianjun1688 2010-01-29
  • 打赏
  • 举报
回复
正愁这事
RFEZGC 2010-01-29
  • 打赏
  • 举报
回复
mark
xiongyuanming 2010-01-27
  • 打赏
  • 举报
回复
楼主这个 数字 这么简单 小学简易方法 都可以搞定 哈哈 纯属娱乐 没有恶意
学习了!!
itliyi 2010-01-27
  • 打赏
  • 举报
回复
[Quote=引用 16 楼 kkkkkkmn 的回复:]
C# codeprotectedvoid Button2_Click(object sender, EventArgs e)
{string tempA=this.TextBox3.Text.Trim();string tempB=this.TextBox4.Text.Trim();int dashu=0;int zaiyitemp=0;int zaizaiyi=0;int tenwei=0;int i= tempA.Length;int j= tempB.Length;string[,] strtemp=newstring[j, i+ j];for (int temi=0; temi< j; temi++)
{for (int temj=0; temj< i+ j; temj++)
{if ((i-1- temj)>=0&& (j-1- temi)>=0)
{
tenwei= Convert.ToInt32(tempA[i-1- temj].ToString())* Convert.ToInt32(tempB[j-1- temi].ToString())+ zaiyitemp;if (tenwei.ToString().Length>1)
{
zaiyitemp= Convert.ToInt16(tenwei.ToString()[0].ToString());if ((i+ j- temj-1- temi)>=0)
{
strtemp[temi, i+ j- temj-1- temi]= (tenwei.ToString()[1]).ToString();
}
}else
{
strtemp[temi, i+ j- temj- temi-1]= tenwei.ToString();
zaiyitemp=0;
}
}else
{if ((i+ j- temj-1- temi)>=0)
{
strtemp[temi, i+ j- temj-1- temi]= zaiyitemp.ToString();
}
zaiyitemp=0;
}
}
}string haha="";string[] jieguo=newstring[i+ j];for (int temp=0; temp< i+ j; temp++)
{for (int temp1=0; temp1< j; temp1++)
{if (strtemp[temp1, i+ j- temp-1]==null)
{
strtemp[temp1, i+ j- temp-1]="0";
}
dashu+= Convert.ToInt32(strtemp[temp1, i+ j- temp-1]);
}
dashu= dashu+ zaizaiyi;if (dashu.ToString().Length>1)
{int templast= dashu.ToString().Length;
zaizaiyi= Convert.ToInt32(dashu.ToString().Substring(0, templast-1));
jieguo[i+ j- temp-1]= dashu.ToString()[templast-1].ToString();
dashu=0;
}else
{
jieguo[i+ j- temp-1]= dashu.ToString();
dashu=0;
zaizaiyi=0;
}
haha= jieguo[i+ j- temp-1]+ haha;
}this.TextBox5.Text= haha;
}
[/Quote]我晕了
ll305vc 2010-01-27
  • 打赏
  • 举报
回复
1.VC中有大整数的,可以用那个
2.自己重载运行符,把字符当数字计算,但这样效率比较低,大学时写过,呵呵
3.用把数字分段计算,这样效率高点,但要注意分段的方式
十八道胡同 2010-01-27
  • 打赏
  • 举报
回复
用数组来模拟乘法
大数乘法
ITJaneLiu 2010-01-27
  • 打赏
  • 举报
回复
支持一下
hw55912346 2010-01-27
  • 打赏
  • 举报
回复
学习
ILOVE_ASPNET 2010-01-27
  • 打赏
  • 举报
回复
mark
whb147 2010-01-27
  • 打赏
  • 举报
回复
学习了
kkkkkkmn 2010-01-27
  • 打赏
  • 举报
回复
例如 1234567896546513219879874654132198765432186789465132185 *
98756413213214687984651321498432121874984351
=121921497331116742110448819663825106030237967037111692302932986659150132515835868005836707021436935

你给的数很小
9999999999999999999999999999*99999999999999999999999999 =
999999999999999999999999989900000000000000000000000001
kkkkkkmn 2010-01-27
  • 打赏
  • 举报
回复

protected void Button2_Click(object sender, EventArgs e)
{
string tempA = this.TextBox3.Text.Trim();
string tempB = this.TextBox4.Text.Trim();
int dashu = 0;
int zaiyitemp = 0;
int zaizaiyi = 0;
int tenwei = 0;
int i = tempA.Length;
int j = tempB.Length;
string[,] strtemp = new string[j, i + j];

for (int temi = 0; temi < j; temi++)
{
for (int temj = 0; temj < i + j; temj++)
{
if ((i - 1 - temj) >= 0 && (j - 1 - temi) >= 0)
{
tenwei = Convert.ToInt32(tempA[i - 1 - temj].ToString()) * Convert.ToInt32(tempB[j - 1 - temi].ToString()) + zaiyitemp;
if (tenwei.ToString().Length > 1)
{
zaiyitemp = Convert.ToInt16(tenwei.ToString()[0].ToString());
if ((i + j - temj - 1 - temi) >= 0)
{
strtemp[temi, i + j - temj - 1 - temi] = (tenwei.ToString()[1]).ToString();
}
}
else
{
strtemp[temi, i + j - temj - temi - 1] = tenwei.ToString();
zaiyitemp = 0;
}
}
else
{
if ((i + j - temj - 1 - temi) >= 0)
{
strtemp[temi, i + j - temj - 1 - temi] = zaiyitemp.ToString();
}
zaiyitemp = 0;
}
}
}

string haha = "";
string[] jieguo = new string[i + j];
for (int temp = 0; temp < i + j; temp++)
{
for (int temp1 = 0; temp1 < j; temp1++)
{
if (strtemp[temp1, i + j - temp - 1] == null)
{
strtemp[temp1, i + j - temp - 1] = "0";
}
dashu += Convert.ToInt32(strtemp[temp1, i + j - temp - 1]);
}
dashu = dashu + zaizaiyi;
if (dashu.ToString().Length > 1)
{
int templast = dashu.ToString().Length;
zaizaiyi = Convert.ToInt32(dashu.ToString().Substring(0, templast - 1));
jieguo[i + j - temp - 1] = dashu.ToString()[templast - 1].ToString();
dashu = 0;
}
else
{
jieguo[i + j - temp - 1] = dashu.ToString();
dashu = 0;
zaizaiyi = 0;
}
haha = jieguo[i + j - temp - 1] + haha;
}
this.TextBox5.Text = haha;
}
kkkkkkmn 2010-01-27
  • 打赏
  • 举报
回复
我编写一段大数相乘的 源代码你要吗
我用的方法老套
使用的 数组方式
samuellei 2010-01-27
  • 打赏
  • 举报
回复
大的整形数组相乘
maxch1225 2010-01-27
  • 打赏
  • 举报
回复
[Quote=引用 12 楼 tchjl2007 的回复:]
百位乘法万位积
[/Quote]
什么意思!?!?
Hamsic 2010-01-27
  • 打赏
  • 举报
回复
百位乘法万位积
angel6709 2010-01-27
  • 打赏
  • 举报
回复
array
liuyu520hong 2010-01-27
  • 打赏
  • 举报
回复
将两个要进行计算的数据分别存入两个数组中进行计算!
m_struggle 2010-01-27
  • 打赏
  • 举报
回复
数组
加载更多回复(13)

110,539

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧