当前位置:网站首页>Exercise 9-6 statistics of student scores by grade (20 points)
Exercise 9-6 statistics of student scores by grade (20 points)
2022-06-11 22:25:00 【Xiaoyan y】
According to the students' grades, the students' grades should be set , And count the number of failed simple function .
Function interface definition :
int set_grade( struct student *p, int n );
among p Is the pointer to the structure array of student information , The structure is defined as :
struct student{
int num;
char name[20];
int score;
char grade;
};
n Is the number of array elements . Student number num、 full name name And achievements score It's all stored .set_grade The function needs to be based on the student's grade score Set its level grade. Level setting :85-100 by A,70-84 by B,60-69 by C,0-59 by D. meanwhile ,set_grade You also need to return the number of people who failed .
Sample referee test procedure :
#include <stdio.h>
#define MAXN 10struct student{
int num;
char name[20];
int score;
char grade;
};int set_grade( struct student *p, int n );
int main()
{ struct student stu[MAXN], *ptr;
int n, i, count;ptr = stu;
scanf("%d\n", &n);
for(i = 0; i < n; i++){
scanf("%d%s%d", &stu[i].num, stu[i].name, &stu[i].score);
}
count = set_grade(ptr, n);
printf("The count for failed (<60): %d\n", count);
printf("The grades:\n");
for(i = 0; i < n; i++)
printf("%d %s %c\n", stu[i].num, stu[i].name, stu[i].grade);
return 0;
}/* Your code will be embedded here */
sample input :
10
31001 annie 85
31002 bonny 75
31003 carol 70
31004 dan 84
31005 susan 90
31006 paul 69
31007 pam 60
31008 apple 50
31009 nancy 100
31010 bob 78
sample output :
The count for failed (<60): 1
The grades:
31001 annie A
31002 bonny B
31003 carol B
31004 dan B
31005 susan A
31006 paul C
31007 pam C
31008 apple D
31009 nancy A
31010 bob B
int set_grade( struct student *p, int n ){
int count=0,i;
for(i=0;i<n;i++){
if(p->score>=85&&p->score<=100){
p->grade='A';
}else if(p->score>=70&&p->score<=84){
p->grade='B';
}else if(p->score>=60&&p->score<=69){
p->grade='C';
}else if(p->score>=0&&p->score<=59){
count++;
p->grade='D';
}
p++;
}
return count;
}
边栏推荐
- 完好性简要介绍
- Why is the printer unable to print the test page
- Basic operation and question type summary of linked list
- SequenceList顺序表的实现
- Conception du Processeur superscalaire Yao yongbin chapitre 2 cache - - sous - section 2.4 extrait
- Is the securities account recommended by qiniu safe? Is it reliable
- 链表基本操作与题型总结
- 习题9-6 按等级统计学生成绩 (20 分)
- [matlab] second order saving response
- 习题8-8 判断回文字符串 (20 分)
猜你喜欢

leetcode 中的位运算

Tkinter study notes (IV)
![[Chongqing Guangdong education] college physics of Xiangtan University: mechanical and thermal reference materials](/img/64/683a190d14406a9971edd79037cc97.jpg)
[Chongqing Guangdong education] college physics of Xiangtan University: mechanical and thermal reference materials
![[Yu Yue education] Yancheng Normal University Advanced Algebra reference](/img/3f/cd7f6f420fb1d453acca9aa73665ba.jpg)
[Yu Yue education] Yancheng Normal University Advanced Algebra reference

论文阅读《Dense Visual SLAM for RGB-D Cameras》

Fastapi 5 - common requests and use of postman and curl (parameters, x-www-form-urlencoded, raw)

astra pro双目相机ros下启动笔记

Tkinter study notes (III)

Precision twist jitter

学1个月爬虫就月赚6000?别被骗了,老师傅告诉你爬虫的真实情况
随机推荐
[nodejs] electron installation
Glory earbud 3 Pro with three global first strong breakdowns flagship earphone Market
Addition without addition, subtraction, multiplication, Division
Determine whether the linked list is palindrome structure
【Uniapp 原生插件】商米钱箱插件
习题6-2 使用函数求特殊a串数列和 (20 分)
[uniapp native plug-in] shangmi cashbox plug-in
Optimization of quick sort
Conception du Processeur superscalaire Yao yongbin chapitre 2 cache - - sous - section 2.4 extrait
Bit operation in leetcode
Precision twist jitter
练习8-8 移动字母 (10 分)
Study notes of mattlotlib and Tkinter (I)
Implementation of stack stack
Learning bit segment (1)
LeetCode栈题目总结
Win10弹出USB时出现该设备正在使用的解决方法
Basic operation and question type summary of binary tree
3.3 测试模块的命名规则
判断链表是否为回文结构