求LC-2K汇编语言(Assembly Language)的算组合数C(n,r)的代码.已经写出,但步骤太多,望高手帮优化一要求使用遗传算法:your assembly-language program will followthis logic closely.int combination(int n,int r){if (r
来源:学生作业帮助网 编辑:作业帮 时间:2024/07/19 21:55:30
![求LC-2K汇编语言(Assembly Language)的算组合数C(n,r)的代码.已经写出,但步骤太多,望高手帮优化一要求使用遗传算法:your assembly-language program will followthis logic closely.int combination(int n,int r){if (r](/uploads/image/z/1672334-62-4.jpg?t=%E6%B1%82LC-2K%E6%B1%87%E7%BC%96%E8%AF%AD%E8%A8%80%EF%BC%88Assembly+Language%EF%BC%89%E7%9A%84%E7%AE%97%E7%BB%84%E5%90%88%E6%95%B0C%EF%BC%88n%2Cr%EF%BC%89%E7%9A%84%E4%BB%A3%E7%A0%81.%E5%B7%B2%E7%BB%8F%E5%86%99%E5%87%BA%2C%E4%BD%86%E6%AD%A5%E9%AA%A4%E5%A4%AA%E5%A4%9A%2C%E6%9C%9B%E9%AB%98%E6%89%8B%E5%B8%AE%E4%BC%98%E5%8C%96%E4%B8%80%E8%A6%81%E6%B1%82%E4%BD%BF%E7%94%A8%E9%81%97%E4%BC%A0%E7%AE%97%E6%B3%95%EF%BC%9Ayour+assembly-language+program+will+followthis+logic+closely.int+combination%28int+n%2Cint+r%29%7Bif+%28r)
求LC-2K汇编语言(Assembly Language)的算组合数C(n,r)的代码.已经写出,但步骤太多,望高手帮优化一要求使用遗传算法:your assembly-language program will followthis logic closely.int combination(int n,int r){if (r
求LC-2K汇编语言(Assembly Language)的算组合数C(n,r)的代码.已经写出,但步骤太多,望高手帮优化一
要求使用遗传算法:
your assembly-language program will follow
this logic closely.
int combination(int n,int r)
{
if (r==0 || n==r) {
return(1);
} else {
return(combination(n-1,r) + combination(n-1,r-1));
}
}
LC-2K汇编代码如下:
lw 0 1 n
lw 0 2 r
lw 0 6 combAd
jalr 6 7
halt
comb lw 0 6 num1
sw 5 7 stack
add 5 6 5
sw 5 1 stack
add 5 6 5
sw 5 2 stack
add 5 6 5
sw 5 4 stack
add 5 6 5
beq 2 0 rat
beq 1 2 rat
lw 0 6 neg1
add 1 6 1
lw 0 6 combAd
jalr 6 7
add 0 3 4
lw 0 6 neg1
add 2 6 2
lw 0 6 combAd
jalr 6 7
add 4 3 3
beq 0 0 ret
rat add 0 6 3
ret lw 0 6 neg1
add 5 6 5
lw 5 4 stack
add 5 6 5
lw 5 2 stack
add 5 6 5
lw 5 1 stack
add 5 6 5
lw 5 7 stack
jalr 7 6
n .fill 7
r .fill 4
num1 .fill 1
neg1 .fill -1
combAd .fill comb
求LC-2K汇编语言(Assembly Language)的算组合数C(n,r)的代码.已经写出,但步骤太多,望高手帮优化一要求使用遗传算法:your assembly-language program will followthis logic closely.int combination(int n,int r){if (r
我是丁老师,a.k.a.Robert Dick.
Hopefully you can optimize the code all by yourself.You know,this is a very important procedure for a coder to optimize the code to work well.
Good luck!