#include <stdio.h>
#define STUDENTS 5
typedef struct{
int id;
int english;
int class;
}Student;
void classify(Student*data);
int main(void) {
Student data[]={{1,60},
{2,80},
{3,90},
{4,70},
{5,50}};
classify(data);
for(int i=0;i<STUDENTS;i++){
printf("%d,%c\n",data
[i
].
id,data
[i
].
class); }
return 0;
}
void classify(Student*data){
for(int i=0;i<STUDENTS;i++){
if(data[i].english>=80){
data[i].class='A';
}
else if(data[i].english>=70){
data[i].class='B';
}
else if(data[i].english>=60){
data[i].class='C';
}
else{
data[i].class='D';
}
}
}
I2luY2x1ZGUgPHN0ZGlvLmg+CiNkZWZpbmUgU1RVREVOVFMgNQp0eXBlZGVmIHN0cnVjdHsKCWludCBpZDsKCWludCBlbmdsaXNoOwoJaW50IGNsYXNzOwp9U3R1ZGVudDsKdm9pZCBjbGFzc2lmeShTdHVkZW50KmRhdGEpOwoKaW50IG1haW4odm9pZCkgewoJU3R1ZGVudCBkYXRhW109e3sxLDYwfSwKCSAgICAgICAgICAgICAgICB7Miw4MH0sCgkgICAgICAgICAgICAgICAgezMsOTB9LAoJICAgICAgICAgICAgICAgIHs0LDcwfSwKCSAgICAgICAgICAgICAgICB7NSw1MH19OwoJY2xhc3NpZnkoZGF0YSk7Cglmb3IoaW50IGk9MDtpPFNUVURFTlRTO2krKyl7CgkJcHJpbnRmKCIlZCwlY1xuIixkYXRhW2ldLmlkLGRhdGFbaV0uY2xhc3MpOwoJfQoJcmV0dXJuIDA7Cn0Kdm9pZCBjbGFzc2lmeShTdHVkZW50KmRhdGEpewoJZm9yKGludCBpPTA7aTxTVFVERU5UUztpKyspewoJCWlmKGRhdGFbaV0uZW5nbGlzaD49ODApewoJCQlkYXRhW2ldLmNsYXNzPSdBJzsKCQl9CgkJZWxzZSBpZihkYXRhW2ldLmVuZ2xpc2g+PTcwKXsKCQkJZGF0YVtpXS5jbGFzcz0nQic7CgkJfQoJCWVsc2UgaWYoZGF0YVtpXS5lbmdsaXNoPj02MCl7CgkJCWRhdGFbaV0uY2xhc3M9J0MnOwoJCX0KCQllbHNlewoJCQlkYXRhW2ldLmNsYXNzPSdEJzsKCQl9Cgl9Cn0K