Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define _CRT_SECURE_NO_WARNINGS
- #include<stdio.h>
- #include<string.h>
- #include<stdlib.h>
- typedef struct sponzor SPONZORI[3];
- typedef struct sponzor{
- char ime[20];
- int budzet;
- }SPONZOR;
- typedef struct igrac{
- char ime[20];
- char tim[20];
- int poz;
- int brS;
- SPONZORI sponzori;
- }IGRAC;
- typedef struct igrac TIM[20];
- void unesiIgraca(IGRAC *ig){
- printf("Unesi ime: ");
- fflush(stdin);
- scanf("%s", &(*ig).ime);
- printf("Unesi tim: ");
- fflush(stdin);
- scanf("%s", &ig->tim);
- printf("Unesi poz: ");
- scanf("%d", &(*ig).poz);
- printf("Unesi br sp: ");
- scanf("%d", &(*ig).brS);
- for (int i = 0; i < ig->brS; i++)
- {
- printf("Unesi naziv sponzora: ");
- fflush(stdin);
- scanf("%s", &ig->sponzori[i].ime);
- printf("Budzet: ");
- scanf("%d", &(*ig).sponzori[i].budzet);
- }
- printf("\n");
- }
- void ispisi(IGRAC igrac){
- printf("Ime igraca: %s\nTim: %s\nPozicija: %d\n", igrac.ime, igrac.tim, igrac.poz);
- printf("Sponzori igraca:\n");
- for (int i = 0; i < igrac.brS; i++)
- {
- printf("Ime sponzora: %s\nBudzet: %d\n", igrac.sponzori[i].ime, igrac.sponzori[i].budzet);
- }
- printf("\n");
- }
- void unesiIgracaUTIM(TIM tim, int *brel){
- char odg = ' ';
- IGRAC novi;
- while (odg != 'n')
- {
- unesiIgraca(&novi);
- tim[*brel] = novi;
- (*brel)++;
- printf("D ili N\n");
- fflush(stdin);
- scanf("%c", &odg);
- }
- }
- void ispisiTim(TIM tim, int brel){
- for (int i = 0; i < brel; i++)
- {
- ispisi(tim[i]);
- }
- }
- void prosecanBudzetSponzora(TIM tim, int brel){
- int i, j;
- int zbir = 0;
- int brojSpUCelom = 0;
- for ( i = 0; i < brel; i++)
- {
- for ( j = 0; j < tim[i].brS; j++)
- {
- zbir += tim[i].sponzori[j].budzet;
- brojSpUCelom++;
- }
- }
- printf("Prosecan budzet ke %lf\n", (double)zbir/brojSpUCelom);
- }
- int main(void){
- TIM tim;
- int brel = 0;
- unesiIgracaUTIM(tim, &brel);
- ispisiTim(tim, brel);
- prosecanBudzetSponzora(tim, brel);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement