parent
bdde1cfcaa
commit
488d3e5f07
@ -0,0 +1,67 @@
|
|||||||
|
|
||||||
|
#include<stdio.h>
|
||||||
|
#include<string.h>
|
||||||
|
|
||||||
|
struct student{
|
||||||
|
char study[5];
|
||||||
|
int grade;
|
||||||
|
char name[10];
|
||||||
|
float gradeone;
|
||||||
|
float gradetwo;
|
||||||
|
float gradethree;
|
||||||
|
};
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
struct student grade[3];
|
||||||
|
strcpy(grade[0].study, "10001");
|
||||||
|
grade[0].grade = 11;
|
||||||
|
strcpy(grade[0].name, "Liang");
|
||||||
|
grade[0].gradeone = 99.5;
|
||||||
|
grade[0].gradetwo = 88.5;
|
||||||
|
grade[0].gradethree = 89.5;
|
||||||
|
|
||||||
|
strcpy(grade[1].study, "10002");
|
||||||
|
grade[1].grade = 12;
|
||||||
|
strcpy(grade[1].name, "Zhang");
|
||||||
|
grade[1].gradeone = 77.9;
|
||||||
|
grade[1].gradetwo = 56.5;
|
||||||
|
grade[1].gradethree = 87.5;
|
||||||
|
|
||||||
|
strcpy(grade[2].study, "10003");
|
||||||
|
grade[2].grade = 11;
|
||||||
|
strcpy(grade[2].name, "Wang");
|
||||||
|
grade[2].gradeone = 92.5;
|
||||||
|
grade[2].gradetwo = 99.0;
|
||||||
|
grade[2].gradethree = 60.5;
|
||||||
|
|
||||||
|
char yonghu[10];
|
||||||
|
scanf("%s", yonghu);
|
||||||
|
|
||||||
|
int i;
|
||||||
|
for (i = 0; i < 3; i++) {
|
||||||
|
if(strcmp(yonghu, grade[i].study) == 0 || strcmp(yonghu, grade[i].name) == 0)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
for(int j = 0; j < 3; j++){
|
||||||
|
if(j != i) {
|
||||||
|
printf("%s %d %s %.1f %.1f %.1f\n", grade[j].study, grade[j].grade, grade[j].name, grade[j].gradeone, grade[j].gradetwo, grade[j].gradethree);
|
||||||
|
} else {
|
||||||
|
printf("%s %d %s %.1f %.1f %.1f\n", grade[j + 1].study, grade[j + 1].grade, grade[j + 1].name, grade[j + 1].gradeone, grade[j + 1].gradetwo, grade[j + 1].gradethree);
|
||||||
|
j=j+1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("Are you sure (Yes/No)?");
|
||||||
|
char answer;
|
||||||
|
scanf(" %c", &answer);
|
||||||
|
|
||||||
|
if(answer == 'N') {
|
||||||
|
for(int j = 0; j < 3; j++){
|
||||||
|
printf("%s %d %s %.1f %.1f %.1f\n", grade[j].study, grade[j].grade, grade[j].name, grade[j].gradeone, grade[j].gradetwo, grade[j].gradethree);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
Loading…
Reference in new issue