Advertisement
lazar955

Untitled

Aug 7th, 2016
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.94 KB | None | 0 0
  1. #define _CRT_SECURE_NO_WARNINGS
  2.  
  3. #include<stdio.h>
  4. #include<string.h>
  5. #include<stdlib.h>
  6.  
  7. typedef struct sponzor SPONZORI[3];
  8.  
  9. typedef struct sponzor{
  10. char ime[20];
  11. int budzet;
  12. }SPONZOR;
  13.  
  14. typedef struct igrac{
  15. char ime[20];
  16. char tim[20];
  17. int poz;
  18. int brS;
  19. SPONZORI sponzori;
  20. }IGRAC;
  21.  
  22. typedef struct igrac TIM[20];
  23.  
  24. void unesiIgraca(IGRAC *ig){
  25.  
  26. printf("Unesi ime: ");
  27. fflush(stdin);
  28. scanf("%s", &(*ig).ime);
  29.  
  30. printf("Unesi tim: ");
  31. fflush(stdin);
  32. scanf("%s", &ig->tim);
  33.  
  34. printf("Unesi poz: ");
  35. scanf("%d", &(*ig).poz);
  36.  
  37. printf("Unesi br sp: ");
  38. scanf("%d", &(*ig).brS);
  39.  
  40.  
  41.  
  42. for (int i = 0; i < ig->brS; i++)
  43. {
  44. printf("Unesi naziv sponzora: ");
  45. fflush(stdin);
  46. scanf("%s", &ig->sponzori[i].ime);
  47.  
  48. printf("Budzet: ");
  49. scanf("%d", &(*ig).sponzori[i].budzet);
  50.  
  51. }
  52.  
  53. printf("\n");
  54.  
  55.  
  56. }
  57.  
  58. void ispisi(IGRAC igrac){
  59. printf("Ime igraca: %s\nTim: %s\nPozicija: %d\n", igrac.ime, igrac.tim, igrac.poz);
  60.  
  61. printf("Sponzori igraca:\n");
  62. for (int i = 0; i < igrac.brS; i++)
  63. {
  64. printf("Ime sponzora: %s\nBudzet: %d\n", igrac.sponzori[i].ime, igrac.sponzori[i].budzet);
  65. }
  66.  
  67. printf("\n");
  68. }
  69.  
  70. void unesiIgracaUTIM(TIM tim, int *brel){
  71. char odg = ' ';
  72. IGRAC novi;
  73. while (odg != 'n')
  74. {
  75. unesiIgraca(&novi);
  76. tim[*brel] = novi;
  77. (*brel)++;
  78.  
  79. printf("D ili N\n");
  80. fflush(stdin);
  81. scanf("%c", &odg);
  82. }
  83.  
  84. }
  85.  
  86. void ispisiTim(TIM tim, int brel){
  87. for (int i = 0; i < brel; i++)
  88. {
  89. ispisi(tim[i]);
  90. }
  91.  
  92. }
  93.  
  94. void prosecanBudzetSponzora(TIM tim, int brel){
  95. int i, j;
  96. int zbir = 0;
  97. int brojSpUCelom = 0;
  98. for ( i = 0; i < brel; i++)
  99. {
  100. for ( j = 0; j < tim[i].brS; j++)
  101. {
  102. zbir += tim[i].sponzori[j].budzet;
  103. brojSpUCelom++;
  104. }
  105. }
  106.  
  107. printf("Prosecan budzet ke %lf\n", (double)zbir/brojSpUCelom);
  108. }
  109.  
  110. int main(void){
  111. TIM tim;
  112. int brel = 0;
  113.  
  114. unesiIgracaUTIM(tim, &brel);
  115. ispisiTim(tim, brel);
  116.  
  117. prosecanBudzetSponzora(tim, brel);
  118.  
  119. return 0;
  120. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement