#include #define MAX_GRADE 100 #define STUDENTS 10 int grades[STUDENTS]; int idx; int total = 0; int max_grade = 0; int max_graded_person = 0; int main() { for( idx=0 ;idx < STUDENTS; idx++) { printf("A %d. tanuló pontszáma : ", idx +1); scanf( "%d", &grades[idx] ); while ( grades[idx] > MAX_GRADE ) { printf( "\n A maximális pontszám : %d", MAX_GRADE ); printf( "\n Írj be egy helyes pontszámot : " ); scanf( "%d", &grades[idx] ); } } /* Megszámoljuk a jegyek összegét -> végig kell menni a tömbön */ for( idx=0 ;idx < STUDENTS; idx++) { total += grades[idx]; } /* Megnézzük ki kapott maximális pontszámot */ max_grade = grades[0]; for( idx=1 ;idx < STUDENTS; idx++) { if(grades[idx] > max_grade) { max_grade = grades[idx]; max_graded_person = idx; } } printf( "\nAz átlag pontszám: %d\n", ( total / STUDENTS) ); printf( "Az első legtöbbet elért hallgató a %d sorszámú és pontszáma %d\n", max_graded_person+1, max_grade); return 0; }