MIPS 汇编 水仙花数
来源:互联网 发布:比斯利数据 编辑:程序博客网 时间:2024/05/17 07:43
求100-999中的水仙花数,(若三位数abc,abc=a^3+b^3+c^3, 则称abc为水仙花数。如153,1^3+5^3+3^3=1+125+27=153,则153是水仙花数)#include<stdio.h>int main(){int i;int a,b,c;for(i=100;i<1000;i++){ a=i/100; b=(i%100)/10; c=i%10; if(i==a*a*a+b*b*b+c*c*c) printf("%d\n",i); else continue;} } 以下汇编:.dataspace:.asciiz " ".textli $t0,100 #use $t0 as ili $t1,10li $t2 100li $s0,1000fori:slt $s1,$t0,$s0beq $s1,$0,endforidiv $t0,$t2mflo $t3 #use $t3 as amfhi $t4div $t4,$t1mflo $t4 #use $t4 as bdiv $t0,$t1mfhi $t5 #use $t5 as cmult $t3,$t3mflo $t6mult $t6,$t3mflo $t3 #use $t3 as a^3mult $t4,$t4mflo $t6mult $t6,$t4mflo $t4#use $t3 as a^3mult $t5,$t5mflo $t6mult $t6,$t5mflo $t5 #use $t3 as a^3add $t6,$t3,$t4add $t6,$t6,$t5beq $t6,$t0,print addi $t0,$t0,1j fori endfori:j endprint:move $a0,$t0li $v0,1syscallla $a0,spaceli $v0,4syscalladdi $t0,$t0,1j foriend:li $v0,10syscall
阅读全文
0 0
- MIPS 汇编 水仙花数
- 汇编---水仙花数算法
- MIPS 汇编
- MIPS汇编
- 水仙花数
- 水仙花数
- 水仙花数
- 水仙花数
- 水仙花数
- 水仙花数
- 水仙花数
- 水仙花数
- 水仙花数
- 水仙花数
- 水仙花数
- 水仙花数
- 水仙花数
- 水仙花数
- 深度优先搜索示例
- 【C0001-笔记】std::nothrow不抛异常置空指针
- [LeetCode] 3. Longest Substring Without Repeating Characters
- SQL数据库基本概念
- 拦截器类
- MIPS 汇编 水仙花数
- RPC入门总结(六)Thrift的介绍和用法
- 【Mybatis】通过自动回复机器人学Mybatis---基础版(1-3)
- 我国人工智能技术发展迅猛
- STM32F407 关于TIM1输出PWM
- 【数据结构】简单迷宫:假设只有一个出口
- 日记(周末)
- (int)a,&a,(int)&a,(int&)a区别
- PAT1019 数字黑洞