0
我有任务做,我设法做的第一部分:阵列反射基本任务
// create an array B that has twice as many elements as A and is
// A forward followed by A in reverse
// if A is {3, 22, -5, 7} then we create B {3, 22, -5, 7, 7, -5, 22, 3}
// array A is declared and the size of A is 'size'
// myapproach
int B[2*size];
int i;
for (i = size; i >-1 ; i--) {
B[i] = A[i];
}
int j; int k;
for (j = 2*size; j>size; i--) {
k = size;
k++;
while (2*size < k) {
B[j] = B[k];
}
}
我的代码工作的任务的第一部分(B = {3,22,-5, 7,})但我找不出其他的。你能帮我吗?
你应该只需要2个循环总数和没有嵌套循环。你也是第一个循环应该从'size-1'而不是'size'。 '[尺寸]'将超出界限。 – twain249