Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- typedef struct Student{
- int id; //學生座號
- int english; //學生英文成績
- int chinese; //學生中文成績
- int math; //學生數學成績
- } Student;
- int main(){
- int n;
- scanf("%d", &n);
- Student s[1000];
- int i;
- for( i = 0 ; i < n ; i++ ){
- scanf("%d%d%d%d", &s[i].id,
- &s[i].english,
- &s[i].chinese,
- &s[i].math );
- }
- int maxStudent = 0;
- for( i = 1 ; i < n ; i++ ){
- if( s[i].english + s[i].chinese + s[i].math >
- s[maxStudent].english + s[maxStudent].chinese + s[maxStudent].math ){
- maxStudent = i;
- }
- }
- printf("%d\n", s[maxStudent].id);
- return 0;
- }
Add Comment
Please, Sign In to add comment