# 在c中填充2d数组的第二列

``````#include <stdio.h>

void main()
{
int Temperature[5][2] = {{20},{21},{22},{23},{24}};

printf("I created a 2D array of size 5x2,");
printf("and I filled the first column with random values in the range [20,25]\n");

for(int i=0; i<5; i++)
{
printf("%d ",Temperature[i][0]);
printf("\n");
}

printf("Please fill the second column with values in the range [0,20]\n");

int i, j;
for(j=0;j<5;j++)
{
printf("Value[%d]:",j);
scanf("%d", &Temperature[0][j]);
}
}
``````

``````#include <stdio.h>

void main()
{
int Temperature[5][2]={{20},{21},{22},{23},{24}};
printf("I created a 2D array of size 5x2,");
printf("and I filled the first column with random values in the range [20,25]\n");
for(int i=0; i<5; i++)
{
printf("%d ",Temperature[i][0]);
printf("\n");
}
printf("Please fill the second column with values in the range [0,20]\n");
int i, j;
for(j=0;j<5;j++)
{
printf("Value[%d]:",j);
scanf("%d", &Temperature[j][1]);
}
}
``````
David
``````&Temperature[0][j]
``````

The actual element would be under `Temperature[j][1]`.