c语言统计成绩各分数段,题目学生成绩统计用c语言从键盘输入一个班全班最..._统计师_帮考网...

ffd6ac8b64ae3ad2c6d02f2b36d5143f.png

cantucuo

高能答主

07-08

TA获得超过4728个赞

#include "stdio.h"

/*学生信息*/

struct student

{

int num;

char name[20];

float score;

}stu[5];

/*输入学生成绩*/

input()

{

int i;

for(i=0;i<5;i++)

scanf("%d%s%f",&stu[i].num,stu[i].name,&stu[i].score);

}

/*求最高成绩并输出*/

high()

{

int i, m;

float maxscore;

m = 0;

maxscore = stu[0].score;

for (i = 1; i     {

if (stu[i].score > maxscore)

{

maxscore = stu[i].score;

m = i;

}

}

printf("The maxmum score is :%5.1f", maxscore);

printf("The student number is: %d", stu[m].num);

printf("The student name is: %s", stu[m].name);

}

/*求最低成绩并输出*/

low()

{

int i, m;

float minscore;

m = 0;

minscore = stu[0].score;

for (i = 1; i     {

if (stu[i].score         {

minscore = stu[i].score;

m = i;

}

}

printf("The minmum score is :%5.1f", minscore);

printf("The student number is: %d", stu[m].num);

printf("The student name is: %s", stu[m].name);

}

/*从高到低排序*/

sort()

{

int i,j,t1;

float t;

char na[20];

for(i=0;i<4;i++)

for(j=i+1;j<5;j++)

if(stu[i].score{

t=stu[i].score;

stu[i].score=stu[j].score;

stu[j].score=t;

t1=stu[i].num;

stu[i].num=stu[j].num;

stu[j].num=t1;

strcpy(na,stu[i].name);

strcpy(stu[i].name,stu[j].name);

strcpy(stu[j].name,na);

}

}

/*输出排序后的成绩*/

outputsort()

{

int i;

for(i=0;i<5;i++)

printf("%d,%s,%f",stu[i].num,stu[i].name,stu[i].score);

}

/*求不及格的人数并输出,输出不及格的学生信息*/

nopass()

{

int i,j=0;

for(i=0;i<5;i++)

if(stu[i].score<60)

{

printf("%d,%s,%f",stu[i].num,stu[i].name,stu[i].score);

j++;

}

printf("不及格的人数为%d",j);

}

void main()

{

input();

high();

low();

sort();

outputsort();

nopass();

getch();

}

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值