[COLOR="#008000"]#include<stdio.h>
#define MAX_IME 20
#define MAX_PREZIME 30
#define MAX_STUDENATA 100[/COLOR]
[B]typedef [/B][B]struct [/B]studenti
{
[B]char [/B]ime[[COLOR="#EE82EE"]MAX_IME[/COLOR]];
[B]char [/B]prezime[[COLOR="#EE82EE"]MAX_PREZIME[/COLOR]];
[B]int [/B]brojindeksa, ocena;
} Studenti;
Studenti student[[COLOR="#EE82EE"]MAX_STUDENATA[/COLOR]];
[B]int [/B]broj_studenata = [COLOR="#EE82EE"]0[/COLOR];
[B]int [/B]ucitaj_studenta(FILE *f, Studenti *s)
{
[B]int [/B]rez = fscanf(f, [COLOR="#FF0000"]"%s%s%d%d"[/COLOR], s->ime, s->prezime, &(s->brojindeksa), &(s->ocena));
[B]if[/B](rez != [COLOR="#EE82EE"]4[/COLOR])
[B]return [/B][COLOR="#EE82EE"]0[/COLOR];
[B]return [/B][COLOR="#EE82EE"]1[/COLOR];
}
[B]void [/B]ispisi_studente()
{
[B]int [/B]i;
[B]for[/B](i = [COLOR="#EE82EE"]0[/COLOR]; i < broj_studenata; i++)
printf([COLOR="#FF0000"]"%-10s %-15s %-15d %-5d\n"[/COLOR], student[i].ime, student[i].prezime, student[i].brojindeksa, student[i].ocena);
}
[B]int [/B]main()
{
FILE *f;
[B]int [/B]i;
f = fopen([COLOR="#FF0000"]"ocene.txt"[/COLOR], [COLOR="#FF0000"]"r"[/COLOR]);
[B]if[/B](f == NULL)
{
printf([COLOR="#FF0000"]"Greska prilikom otvaranja datoteke\n"[/COLOR]);
[B]return [/B][COLOR="#EE82EE"]1[/COLOR];
}
[B]while[/B](ucitaj_studenta(f, &student[broj_studenata]))
broj_studenata++;
printf([COLOR="#FF0000"]"Ime Prezime Broj indeksa Ocena\n"[/COLOR]);
printf([COLOR="#FF0000"]"-------------------------------------------------------------\n"[/COLOR]);
ispisi_studente();
printf([COLOR="#FF0000"]"-------------------------------------------------------------\n"[/COLOR]);
printf([COLOR="#FF0000"]"Studenti koji su polozili\n"[/COLOR]);
printf([COLOR="#FF0000"]"Ime Prezime Broj indeksa Ocena\n"[/COLOR]);
printf([COLOR="#FF0000"]"-------------------------------------------------------------\n"[/COLOR]);
[B]for[/B](i = [COLOR="#EE82EE"]0[/COLOR]; i < broj_studenata; i++)
[B]if[/B](student[i].ocena > [COLOR="#EE82EE"]5[/COLOR])
printf([COLOR="#FF0000"]"%-10s %-15s %-15d %-5d\n"[/COLOR], student[i].ime, student[i].prezime, student[i].brojindeksa, student[i].ocena);
printf([COLOR="#FF0000"]"-------------------------------------------------------------\n"[/COLOR]);
printf([COLOR="#FF0000"]"Studenti koji nisu polozili\n"[/COLOR]);
printf([COLOR="#FF0000"]"Ime Prezime Broj indeksa Ocena\n"[/COLOR]);
printf([COLOR="#FF0000"]"-------------------------------------------------------------\n"[/COLOR]);
[B]for[/B](i = [COLOR="#EE82EE"]0[/COLOR]; i < broj_studenata; i++)
[B]if[/B](student[i].ocena == [COLOR="#EE82EE"]5[/COLOR])
printf([COLOR="#FF0000"]"%-10s %-15s %-15d %-5d\n"[/COLOR], student[i].ime, student[i].prezime, student[i].brojindeksa, student[i].ocena);
printf([COLOR="#FF0000"]"-------------------------------------------------------------\n"[/COLOR]);
fclose(f);
}