-->
当前位置:首页 > 题库 > 正文内容

FILL_IN_THE_BLANK_FOR_PROGRAMMING:Grade conversion

Luz3年前 (2021-05-10)题库277
Enter a positive integer n, and then enter the names of n students and the percentile score, which will be converted into two-level score output. The function set is required to be defined and called_ The function of grade (stu, n) is to convert the student's percentile score stored in stu into a two-level score and assign it to grade. The conversion rule from the 100 point system to the two-level system: P is greater than or equal to 60 points, otherwise F.
```c++
#include
#define MAXN 100
struct student{
char name[20];
int score;
char grade;
};
void set_ grade( struct student *p, int n );
int main()
{
int i, n;
struct student stu[MAXN];
scanf("%d", &n);
for(i = 0; i < n; i++){
scanf("%s%d", stu[i].name, &stu[i].score);
}
set_ grade(stu, n);
for(i = 0; i < n; i++)
printf("%s %c\n", stu[i].name, stu[i].grade);
return 0;
}
void set_ grade(struct student *p, int n)
{
struct student *q = p + n - 1;
while( @@[p <= q](1) ){
@@[if ( p->score >= 60 ) p->grade = 'P';]( 1)
@@[else p->grade = 'F';]( 1)
p++;
}
}
```






answer:The first null: P < = q
The second blank: if (P - > score > = 60) P - > grade ='p ';
The third null: else p - > grade ='f ';

发表评论

访客

◎欢迎参与讨论,请在这里发表您的看法和观点。