试编写一程序段,要求把BL中的数除以CL中的数,并把其商乘以2,最后的结果存入DX寄存器中。

试编写一程序段,要求把BL中的数除以CL中的数,并把其商乘以2,最后的结果存入DX寄存器中。,第1张

assume cs:code

code segment

start:

mov bx,2222h

mov cx,1111h

mov al,bl

mov ah,0

div cl

mov dl,2

mul dl

mov dx,0

mov dx,ax

mov ax,4c00h

int 21h

code ends

end start

您好,你的问题,我之前好像也遇到过,以下是我原来的解决思路和方法,希望能帮助到你,若有错误,还望见谅!展开全部

#include <iostream>

using namespace std

int main ()

{long int num

int indiv,ten,hundred,thousand,ten_thousand,place

/*分别代表个位,十位,百位,千位,万位和位数*/

cout<<"enter an integer(0~99999):"

cin>>num

if (num>9999)

place=5

else if (num>999)

place=4

else if (num>99)

place=3

else if (num>9)

place=2

else place=1

cout<<"place="<<place<<endl

//计算各位数字

ten_thousand=num/10000

thousand=(int)(num-ten_thousand*10000)/1000

hundred=(int)(num-ten_thousand*10000-thousand*1000)/100

ten=(int)(num-ten_thousand*10000-thousand*1000-hundred*100)/10

indiv=(int)(num-ten_thousand*10000-thousand*1000-hundred*100-ten*10)

cout<<"original order:"

switch(place)

{case 5:cout<<ten_thousand<<","<<thousand<<","<<hundred<<","<<ten<<","<<indiv<<endl

cout<<"reverse order:"

cout<<indiv<<ten<<hundred<<thousand<<ten_thousand<<endl

break

case 4:cout<<thousand<<","<<hundred<<","<<ten<<","<<indiv<<endl

cout<<"reverse order:"

cout<<indiv<<ten<<hundred<<thousand<<endl

break

case 3:cout<<hundred<<","<<ten<<","<<indiv<<endl

cout<<"reverse order:"

cout<<indiv<<ten<<hundred<<endl

break

case 2:cout<<ten<<","<<indiv<<endl

cout<<"reverse order:"

cout<<indiv<<ten<<endl

break

case 1:cout<<indiv<<endl

cout<<"reverse order:"

cout<<indiv<<endl

break

}

return 0

}非常感谢您的耐心观看,如有帮助请采纳,祝生活愉快!谢谢!

int n = 7 //输入的自然数\x0d\x0a int k = 0 //输出的状态控制 初始化为0\x0d\x0a for (int i = 2i 回答于 2022-12-11


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/yw/10983225.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-12
下一篇 2023-05-12

发表评论

登录后才能评论

评论列表(0条)

保存