You can't do it without a hacky shell loop and bad coding practices for letting shell variables expand to become part of an awk command, or a function that populates hard-coded, predefined arrays given a numeric arg or similar. Don't even try it.
If you have or can get GNU awk you should use true multi-dimensional arrays instead:
$ cat file
a b c
d e
f g h
i j k
l m
$ awk -v n=3 '
NR<=n {arrayRow[NR][1]; split($0,arrayRow[NR]) }
END {
for (i in arrayRow) {
for (j in arrayRow[i]) {
print i, j, arrayRow[i][j]
}
}
}
' file
1 1 a
1 2 b
1 3 c
2 1 d
2 2 e
3 1 f
3 2 g
3 3 h
Otherwise you can use pseudo-multi-dimensional arrays in any awk:
$ awk -v n=3 '
NR<=n { for (i=1;i<=NF;i++) arrayRow[NR,i] = $i; nf[NR]=NF }
END {
for (i in nf) {
for (j=1; j<=nf[i]; j++) {
print i, j, arrayRow[i,j]
}
}
}
' file
but you don't actually need multi-dimensional arrays for this at all, just use 1-dimensional and split the string into a new array when you need it:
$ awk -v n=3 '
NR<=n {arrayRow[NR] = $0}
END {
for (i in arrayRow) {
split(arrayRow[i],arrayRowI)
for (j in arrayRowI) {
print i, j, arrayRowI[j]
}
}
}
' file