题目内容

下列程序的功能是输入5个联系人信息,统计年龄分布情况,请填空。struct address{char street[20];int code;int zip; } ;struct nest_friendslist {char name[10];int age;char teltphone[13];struct address addr; } f;int main(void){int i, count1, count2, count3;count1 = count2 = count3 = 0;for(i = 1; i <= 5; i++ ){scanf("%s%d%s", f.name, &f.age, f.teltphone);(); /* 输入地址信息*/if(f.age >= 55) count1++;else if(f.age >= 40) count2++;else count3++; }printf("老年人数:%d, 中年人数:%d, 青年人数:%d\n", count1, count2, count3);return 0;}

查看答案
更多问题

下列程序的功能是输入某班学生的姓名及数学、英语成绩,计算每位学生的平均分,然后输出平均分最高的学生之姓名及数学、英语成绩。请填空。struct student {char name[10]; int math, eng; flost aver; } ;int fun(struct student s[ ], int n){int k, maxsub = 0;for(k = 0; k < n; k++){() = (s[k].math+s[k].eng) / 2.0;if() maxsub = k;}return maxsub;}int main(void){int i, n, maxn;struct student s[50];scanf("%d", &n);for(i = 0; i < n; i++) scanf(%s%d%d", s[i].name, &s[i].math, &s[i].eng);();printf("%10s%3d%3d\n",s[maxn].name, s[maxn].math, s[maxn].eng);return 0;}}

设有三个人的姓名和年龄存在结构数组中,以下程序输出三个人中年龄居中者的姓名和年龄。请填空。static struct man{char name[20];int age;}person[ ] = { “li-ming”,18,"wang-hua",19,"zhang-ping",20 };int main(void){int i, j, max, min;max = min = person[0].age;for(i = 1; i < 3; i++)if(person[i].age > max) ();else if(person[i].age < min) ();for(i = 0; i < 3; i++)if(person[i].age != max () person[i].age != min){printf("%s%d\n", person[i].name, person[i].age);break; }return 0;}

以下程序的运行结果是( )。#include int main(void){struct S {int a, b; } data[2] = {10, 100, 20, 200};struct S p = data[1];printf("%d\n", ++(p.a));return 0;}

以下程序的运行结果是( )。#include struct STU{char name[9]; char sex; int score[2]; } ;void f(struct STU a[ ]){struct STU b = { "zhao", 'm', 85, 90} ;a[1] = b;}int main(void){struct STU c[2] = { {"Qian", 'f', 95, 92"}, {"Sun", 'm', 98, 99} };f(c);printf("%s,%c,%d,%d,", c[0].name, c[0].sex, c[0].score[0], c[0].score[1] );printf("%s,%c,%d,%d", c[1].name, c[1].sex, c[1].score[0], c[1].score[1] );return 0;}

答案查题题库