如何使用J编程语言进行数组访问?例如,使用C++作为我的伪代码语言:
int M [100]; // declare an array called M
int j = 5; //index into the array
int y = 10; //value to store or load from the array
M[j] = y; // store y into the array
y = M[j]; // load y from the array
Run Code Online (Sandbox Code Playgroud)
在惯用的J中,这些类型的数组访问会是什么样的?
printf
您可以打印的值的数量是否有限制?
这是我的代码.
.data
.balign 4
string: .asciz "\n%d %d %d %d\n"
.text
.global main
.extern printf
main:
push {ip, lr} @ push return address + dummy register
@ for alignment
ldr r0, =string @ get address of string into r0
mov r1, #11
mov r2, #22
mov r3, #33
mov r4, #444
bl printf @ print string and pass params
@ into r1, r2, and r3
pop {ip, pc} @ pop return address into pc
Run Code Online (Sandbox Code Playgroud)
当我编译并执行此代码时,它打印出来:
11 22 33 …