Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- struct uczen{
- char imie[30];
- char nazwisko[30];
- int polski;
- int matematyka;
- int przyroda;
- int historia;
- };
- float srednia (struct uczen a)
- {
- return((a.polski + a.matematyka + a.przyroda + a.historia )/4.0);
- }
- void oceny (struct uczen a)
- {
- int temp[4];
- int zliczanie[6];
- for(int i; i<6; ++i)
- {
- zliczanie[i] = 0;
- }
- temp[0] = a.polski;
- temp[1] = a.matematyka;
- temp[2] = a.przyroda;
- temp[3] = a.historia;
- for(int i= 0; i<4; ++i)
- {
- ++zliczanie[temp[i]];
- }
- for(int i = 0; i<6; ++i)
- {
- printf("Liczba wszytskich ocen %d wynoci %d\n", i+1, zliczanie[i]);
- }
- }
- int main()
- {
- struct uczen Nowak = {"Jan", "Nowak", 5, 4, 6, 3};
- struct uczen Kowalski = {"Jakub", "Kowalski", 5, 6, 6, 3};
- struct uczen Lilak = {"Hanna", "Lilak", 5, 4, 6, 3};
- printf("Srednia Nowaka wynoni %.2f\n", srednia(Nowak));
- printf("Srednia Kowalski wynoni %.2f\n", srednia(Kowalski));
- printf("Srednia Lilak wynoni %.2f\n", srednia(Lilak));
- oceny(Nowak);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement