Advertisement
Guest User

Untitled

a guest
Nov 20th, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. struct uczen{
  4. char imie[30];
  5. char nazwisko[30];
  6. int polski;
  7. int matematyka;
  8. int przyroda;
  9. int historia;
  10.  
  11. }tab[3];
  12. float srednia (struct uczen a)
  13. {
  14. return((a.polski + a.matematyka + a.przyroda + a.historia )/4.0);
  15. }
  16.  
  17.  
  18.  
  19. int main()
  20. {
  21. struct uczen Nowak = {"Jan", "Nowak", 5, 4, 6, 3};
  22. struct uczen Kowalski = {"Jakub", "Kowalski", 5, 6, 6, 3};
  23. struct uczen Lilak = {"Hanna", "Lilak", 5, 4, 6, 3};
  24.  
  25. printf("Srednia Nowaka wynoni %.2f\n", srednia(Nowak));
  26. printf("Srednia Kowalski wynoni %.2f\n", srednia(Kowalski));
  27. printf("Srednia Lilak wynoni %.2f\n", srednia(Lilak));
  28.  
  29. struct uczen osoby[] = {Nowak, Kowalski, Lilak};
  30. int zliczanie[6];
  31. for(int i =0; i<6; ++i)
  32. {
  33. zliczanie[i] = 0;
  34. }
  35. for(int i=0; i<3; ++i)
  36. {
  37. ++zliczanie[tab[i].historia - 1];
  38. ++zliczanie[tab[i].przyroda - 1];
  39. ++zliczanie[tab[i].polski - 1];
  40. ++zliczanie[tab[i].matematyka - 1];
  41. }
  42.  
  43. printf("%d\n", tab[0].historia);
  44.  
  45. for(int i=0; i<6; ++i)
  46. {
  47. printf("Ilosc wszystkich %d wynosi %d\n", i+1, zliczanie[i]);
  48. }
  49. return 0;
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement