所以基本上,我希望用户根据他们的家庭规模,根据他们的规模,我想多少次询问他们的年龄(因此输入取决于他们)。
现在,我希望将年龄输入作为数组列表。例如,如果他们是2个,那么我想问他们的年龄两次并保存为
scanf("%d",age[0]);
scanf(%d",age[1]);
在这里我可以想到c代码:
#include <stdio.h>
int main(int n, int age[0]){
printf("enter your family number:");
scanf("%d", n);
}
for(i=1; i>=n; i++){
printf("Can I have your family's age one by one:");
scanf("%d",&age[i]);
}
答案 0 :(得分:0)
#include <stdio.h>
int main(void){
int n;
printf("enter your family number:");
scanf("%d", &n);
int i, age[n];
for(i=0; i<n; ++i){
printf("Can I have your family's age one by one:");
scanf("%d", &age[i]);
}
return 0;
}