我正在尝试将用户输入存储到数组中,但是当我使用sw时,我得到一个错误"存储地址未对齐单词绑定".我的目标是从数组中读取10个整数,但在输入第一个数字后,我在sw命令中得到一个错误.我不知道我做错了什么我花了几个小时试图解决它.任何帮助将非常感谢并标记为有用.
.data
mess: .asciiz " Enter 10 numbers to be stored in the array. "
array: .space 40 #10 element integer array
.globl main
.text
main:
jal read
b done
read:
la $t0, 0 #count variable
b readLoop
jr $ra
readLoop:
beq $t0, 40, read #branch if equal to 40, 10 items
li $v0, 4 #Print string
la $a0, mess #load prompt
syscall
li $v0, 5 #read int
syscall
sw $v0, array #store input in array ERROR HERE
addi $t0, …Run Code Online (Sandbox Code Playgroud) 我试图在数组中找到高低数字,但我不确定为什么我的代码无法正常工作.它给了我0和56的输出.我理解为什么它给0,但56来自哪里?
package test;
public class Test {
public static void main(String[] args) {
int[] numbs = { '2', '4', '2', '8', '4', '2', '5'};
int count = 0;
int low = 0;
int high = 0;
while(count < numbs.length)
{
if(numbs[count]< low) {
low = numbs[count];
}
if(numbs[count]> high) {
high = numbs[count];
}
count++;
}
System.out.println(low);
System.out.println(high);
}
}
Run Code Online (Sandbox Code Playgroud) 我有4个变量,这是我能做的最好的,但是如果有3个真正的变量则返回true.
if(a ^ b ^ c ^ d)
这个函数显示正确的东西,但是如何让这个函数的输出成为另一个函数呢?
;;generate an Caesar Cipher single word encoders
;;INPUT:a number "n"
;;OUTPUT:a function, whose input=a word, output=encoded word
(define encode-n
(lambda (n);;"n" is the distance, eg. n=3: a->d,b->e,...z->c
(lambda (w);;"w" is the word to be encoded
(if (not (equal? (car w) '()))
(display (vtc (modulo (+ (ctv (car w)) n) 26)) ))
(if (not (equal? (cdr w) '()))
((encode-n n)(cdr w)) )
)))
Run Code Online (Sandbox Code Playgroud)