PTA 按等級統計學生成績(C語言)

2021-10-05 05:38:19 字數 858 閱讀 7287

本題要求實現乙個根據學生成績設定其等級,並統計不及格人數的簡單函式。

函式介面定義:

int set_grade( struct student *p, int n );

其中p是指向學生資訊的結構體陣列的指標,該結構體的定義為:

struct student;

n是陣列元素個數。學號num、姓名name和成績score均是已經儲存好的。set_grade函式需要根據學生的成績score設定其等級grade。等級設定:85-100為a,70-84為b,60-69為c,0-59為d。同時,set_grade還需要返回不及格的人數。

裁判測試程式樣例:

#include

#define maxn 10

struct student;

int set_grade( struct student *p, int n );

int main()

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;

}/* 你的**將被嵌在這裡 */

int

set_grade

(struct student *p,

int n )

p++;}

return count;

}

c語言 按等級統計學生成績

本題要求實現乙個根據學生成績設定其等級,並統計不及格人數的簡單函式。函式介面定義 int set grade struct student p,int n 其中p是指向學生資訊的結構體陣列的指標,該結構體的定義為 struct student n是陣列元素個數。學號num 姓名name和成績scor...

按等級統計學生成績

本題要求實現乙個根據學生成績設定其等級,並統計不及格人數的簡單函式。int set grade struct student p,int n 其中p是指向學生資訊的結構體陣列的指標,該結構體的定義為 struct student n是陣列元素個數。學號num 姓名name和成績score均是已經儲存...

按等級統計學生成績

6 2 按等級統計學生成績 20分 本題要求實現乙個根據學生成績設定其等級,並統計不及格人數的簡單函式。函式介面定義 int set grade struct student p,int n 其中p是指向學生資訊的結構體陣列的指標,該結構體的定義為 struct student n是陣列元素個數。學...