(C)一些题21

1.条件语句 while(x){...}中条件表达式 x 的等价写法是 B。
A. x==0 B. x!=0 C. x==1 D. x!=1

2.表达式 1!=2 && 3==5 的值是 C。
A. True B. False C. 0 D. 1

3。. _______125__________。
#include <stdio.h>
int x;
void main()
{ x=5;
cude();
printf("%d\n",x);
}
cude()
{ x=x*x*x; }

4.有 n 个学生,每个学生的数据包括学号(num),姓名(name[20]),性别(sex),年龄(age),三门课的成绩
(score[3])。要求在 main 函数中输入这 n 个学生的数据, 然后调用一个函数 count,在该函数中计算出每个学生的总分和平均分, 然后打印出所有各项数据(包括原有的和新求出的)。

#include <stdio.h>
struct student
{
int num;
char name[20];
char sex;
2
int age;
float score[3];
float total;
float ave;
};
void count(struct student b[],int n)
{
int i,j;
for(i=0;i<n;i++)
{
b[i].total=0 ;
for(j=0;j<3;j++)
b[i].total=b[i].total+b[i].score[j];
b[i].ave=b[i].total/3;
}
}
void main()
{
int i;
float s0,s1,s2;
struct student a[3];
for(i=0;i<3;i++)
{ scanf("%d%s %c%d%f%f%f",&a[i].num,a[i].name,&a[i].sex,&a[i].age,&s0,&s1,&s2);
a[i].score[0]=s0;a[i].score[1]=s1;a[i].score[2]=s2;
printf("%d %s %c %d %4.1f %4.1f %4.1f\n",a[i].num,a[i].name,
a[i].sex,a[i].age,a[i].score[0],a[i].score[1],a[i].score[2]);
}
count(a,3);
printf("==============================================\n");
printf("NO name sex age score[0] score[1] score[2] total ave\n");
for(i=0;i<3;i++)
printf("%d %s %c %d %5.1f %5.1f %5.1f %5.1f %5.1f\n",
a[i].num,a[i].name,a[i].sex,a[i].age,a[i].score[0],
a[i].score[1],a[i].score[2],a[i].total,a[i].ave);
}

  • 8
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值