Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include<string.h>
- #define MAXPATNICI 5
- enum sostojba {stoi,dolu,gore};
- typedef struct
- {
- int sostojba;
- int sprat;
- int brpatnici;
- }lift;
- typedef struct
- {
- int sprat;
- int kade;
- }patnik;
- void povikajlift(patnik *p,lift *l)
- {
- if(p->sprat>l->sprat)
- {
- l->sostojba=1;
- while(l->sprat<p->sprat)
- {
- (l->sprat)++;
- printf("Liftot e na %d sprat\n",l->sprat);
- }
- }
- else if(p->sprat<l->sprat)
- {
- l->sostojba=2;
- while(l->sprat>p->sprat)
- {
- (l->sprat)--;
- printf("Liftot e na %d sprat \n",l->sprat);
- }
- }
- l->sostojba=0;
- printf("Liftot pristigna\n");
- if((l->brpatnici)>MAXPATNICI)
- {
- printf("Liftot ne moze da primi povekje patnici!!!!!\n");
- }
- else
- {
- (l->brpatnici)++;
- if(l->sprat<p->kade)
- {
- l->sostojba=1;
- while(l->sprat<p->kade)
- {
- (l->sprat)++;
- printf("Liftot e na %d sprat",l->sprat);
- }
- }
- else if(l->sprat>p->kade)
- {
- l->sostojba=2;
- while(l->sprat>p->kade)
- {
- (l->sprat)--;
- printf("Liftot e na %d sprat",l->sprat);
- }
- }
- (l->brpatnici)--;
- (l->sostojba)=0;
- }
- }
- intmain()
- {
- lift l={0,0,4};
- patnik p={3,2};
- povikajlift(&p,&l);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement