1
我被要求定义一个名为A的数组,其维数为5X4。我必须初始化它的元素然后从1如何将2维数组的每个元素增加2
#include <stdio.h>
#include <stdlib.h>
#define SIZE 5
#define size 4
int main(){
int A[SIZE][size]={0};
int B[SIZE][size];
int x;
int i;
int j;
for(i = 0; i < SIZE; i++){
for(j = 0; j < size; j++){
for(x = 1; x < 40; x = x + 2){
A[i][j] = x;
printf("%d\n", A[i][j]);
}
}
}
return 0;
}
不幸的是增加它们中的每一个由两个(X + 3),其中X启动,输出为似乎A [1]是给错误和重复值[J]
每个元素的初始值应为0.但是,元素[0] [0]的x值应该为1,然后像[0] [1] ... [ 0] [2] ....等等 – utdlegend
@ut dlegend我做了一些编辑以适合您的要求 – pato
谢谢你现在的作品!你有什么想法为什么X循环不起作用? – utdlegend