2 个数组不会存储输入,每个索引号的增量始终为 0,如 printf 所述。
int main()
{
int ingredientsAmount;
double ingredientsPrice[10];
double ingredientsWeight[10];
scanf("%d", &ingredientsAmount);
for(int i = 0; i < ingredientsAmount; i++)
{
scanf("%lf", &ingredientsPrice[i]);
printf("Price stored at index %lf\n", i);
scanf("%lf", &ingredientsWeight[i]);
printf("Weight stored at index %lf\n", i);
}
return 0;
}