问题 填空题

下面程序的功能是统计在16~31岁之间的学生人数。请填空。 main() {int a[30],n,age,i; for(i=0;i<30;i++)a[i]=0; printf("Enter the number of thestudents(<30)\n"); scanf("%d",&n); printf("Enter the age of each student:\n"); for(i=0;i<n;i++) {scanf("%d",&age);_______;} printf("the result is\n"); printf("age number\n"); for(i=16;i<32;i++) printf("%d%d\n",i,a[i-16]);

答案

参考答案:a[age-16]++

解析:在a[0],a[1]……a[29]中对应存放16,17,18岁…的人数。

选择题
配伍题 B型题