fork download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. struct S {
  5. char KLASA[20];
  6. float OCENY[20][5];
  7. } szkola;
  8.  
  9. void SEREDNIA(struct S szkola,float serednia_ucznia[],float serednia_przedmiotu[])
  10. {
  11. int i,j;
  12. float suma_ucznia[4];
  13. float suma_przedmiotow[2];
  14. for(i=0; i<3; ++i) {
  15. for(j=0; j<2; ++j) {
  16. suma_ucznia[i]+=szkola.OCENY[i][j];
  17. }
  18. printf("%f\n",suma_ucznia[i]);
  19. }
  20. }
  21.  
  22. int main()
  23. {
  24. int i,j;
  25. float serednia_ucznia[3],serednia_przedmiotu[2];
  26. printf("podaj nazwe klasy:\n");
  27. scanf("%s",szkola.KLASA);
  28. for(i=0; i<3; ++i) {
  29. printf("Uczen: %d\n",i+1);
  30. for(j=0; j<2; ++j) {
  31. printf("Przedmiot: %d\n",j+1);
  32. scanf("%f",&szkola.OCENY[i][j]);
  33. }
  34. printf("---------------------------\n");
  35. }
  36. SEREDNIA(szkola,serednia_ucznia,serednia_przedmiotu);
  37. return 0;
  38. }
  39.  
Success #stdin #stdout 0s 2296KB
stdin
ada 1 2 1 2 1 2
stdout
podaj nazwe klasy:
Uczen: 1
Przedmiot: 1
Przedmiot: 2
---------------------------
Uczen: 2
Przedmiot: 1
Przedmiot: 2
---------------------------
Uczen: 3
Przedmiot: 1
Przedmiot: 2
---------------------------
2.999985
3.000000
1.986124