- 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
- 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
- 4、该文档为VIP文档,如果想要下载,成为VIP会员后,下载免费。
- 5、成为VIP后,下载本文档将扣除1次下载权益。下载后,不支持退款、换文档。如有疑问请联系我们。
- 6、成为VIP后,您将拥有八大权益,权益包括:VIP文档下载权益、阅读免打扰、文档格式转换、高级专利检索、专属身份标志、高级客服、多端互通、版权登记。
- 7、VIP文档为合作方或网友上传,每下载1次, 网站将根据用户上传文档的质量评分、类型等,对文档贡献者给予高额补贴、流量扶持。如果你也想贡献VIP文档。上传文档
                        查看更多
                        
                    
                不恢复余数法算法_加减交替法
                    不恢复余数法算法_加减交替法
不恢复余数法算法,附带详细说明,包括软件截图, 
C#只需要拖拽几个控件,2个Label 2个TextBox 1个RichTextBox和一个Button按钮即可。 
using System; 
using System.Collections.Generic; using System.ComponentModel; 
using System.Data; 
using System.Drawing; 
using System.Linq; 
using System.Text;
using System.Windows.Forms; 
namespace 不恢复余数法 
{ 
public partial class Form1 : Form 
{ 
public Form1() 
{ 
InitializeComponent(); 
} 
private void Form1_Load(object sender, EventArgs e) 
{ 
//为button设计快捷键Enter 
this.AcceptButton = button1; 
} 
//余数左移 
private void RemainderLeft(string dividend,string divisor) 
{ 
string x = TrueFormToComplement(dividend); 
string y = TrueFormToComplement(divisor); 
string _y = TrueFormToMinusNumComplement(divisor);
richTextBox1.Text = [X]原= + dividend + \t[|X|]补= + x + \r\n; 
richTextBox1.Text += [Y]原= + divisor + \t[|Y|]补= + y + \t[-|Y|]补=  + _y + \r\n; 
x=x.PadLeft(x.Length+1,x[0]); 
y=y.PadLeft(y.Length+1,y[0]); 
_y=_y.PadLeft(_y.Length+1,_y[0]); 
string remainder = BinaryAdd(x, _y); 
string consult = null; 
int count = divisor.Length - 2; 
for (inti = 0; i count; i++) 
{ 
richTextBox1.Text += 余数, + remainder + \t; 
if (remainder[0] == 1) 
{ 
consult += 0; richTextBox1.Text +=  余数0  +  商, + consult +  \t加除数,[ |Y|]补 + y+\r\n; 
remainder = MoveLeft(remainder); 
remainder= BinaryAdd(remainder, y); 
} 
else 
{ 
consult += 1; richTextBox1.Text +=  余数0  +  商, +
consult +  \t减除数,[-|Y|]补  + _y + \r\n; 
remainder = MoveLeft(remainder); 
remainder= BinaryAdd(remainder, _y); 
} 
} 
richTextBox1.Text += 余数, + remainder; 
if (remainder[0] == 0) 
{ 
consult += 1; 
richTextBox1.Text +=  余数 0 商上 1\r\n; 
} 
else 
{ 
consult += 0; 
richTextBox1.Text +=  余数 0 商上 0 加上[|Y|]补恢复\r\n; 
remainder = BinaryAdd(remainder, y); 
} 
string res = null; 
for (inti = consult.Length - 1, k = 0; k  count; i--, k++) 
{ 
res += consult[i]; 
}
//反转字符串 
string temp = null; 
for (inti = res.Length-1; i= 0; i--) 
{ 
temp += res[i].ToString(); 
} 
//根据被除数与除数决定商的符号 
if (dividend[0] == divisor[0]) 
{ 
temp=temp.Insert(
                 原创力文档
原创力文档 
                        

文档评论(0)