Advertisement
Guest User

Untitled

a guest
Jan 16th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<stdlib.h>
  3.  
  4. struct semestr
  5. {
  6. char nazwa[1000];
  7. float oceny[1000];
  8. };
  9.  
  10. int ilocen[1000];
  11.  
  12. void funkcja(int *m)
  13. {
  14. int n = *m;
  15. struct semestr przedmiot[n];
  16. for(int i=0; i<n; i++)
  17. {
  18. printf("Podaj nazwe %d. przedmiotu: ", i+1);
  19. scanf(" %[^\n]s", przedmiot[i].nazwa);
  20.  
  21. printf("Podaj ilosc ocen przedmiotu %s: ", przedmiot[i].nazwa);
  22. scanf("%d", &ilocen[i]);
  23.  
  24. printf("Podaj oceny:\n");
  25. int j=0;
  26. for(j; j<ilocen[i]; j++){
  27. //printf("JOT: %d\n", j);
  28. printf("Ocena %d.: ", j+1);
  29. scanf("%f", &przedmiot[i].oceny[j]);
  30. }
  31.  
  32. }
  33.  
  34. for(int l=0; l<n; l++){
  35. printf("\nPrzedmiot: %s\nOceny: \n", przedmiot[l].nazwa);
  36. int x = ilocen[l], k=0;
  37. for(k; k<x; k++){
  38. //printf("L: %d K: %d\n", l, k);
  39. printf("%.1f\n\n", przedmiot[l].oceny[k]);
  40. }
  41. //printf("\n\n");
  42. }
  43. printf("KONIEC PROGRAMU");
  44. }
  45.  
  46. int main()
  47. {
  48. int *nn = (int*)malloc(sizeof(int));
  49. printf("Podaj ilosc przedmiotow: ");
  50. scanf("%d", nn);
  51. funkcja(nn);
  52. free(nn);
  53. return 0;
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement