Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- #define RozmiarTablicy 1000
- struct struktura
- {
- int tab[RozmiarTablicy];
- int LiczbaElementow;
- int schowek[RozmiarTablicy];
- int LiczbaKopiowanych;
- }
- ;
- void add(struct struktura* dodaj);
- void rew(struct struktura* odwroc);
- void sho(struct struktura* pokaz);
- int main()
- {
- struct struktura lista;
- lista.LiczbaElementow = 0;
- lista.LiczbaKopiowanych = 0;
- char akcja[4];
- scanf ("%3s", akcja);
- while(1)
- {
- if(strcmp(akcja, "ext")==0)
- break;
- else if(strcmp(akcja, "add")==0)
- add(&lista);
- else if(strcmp(akcja, "sho")==0)
- sho(&lista);
- else if(strcmp(akcja, "rew")==0)
- rew(&lista);
- scanf ("%3s", akcja);
- }
- }
- void add(struct struktura* dodaj)
- {
- scanf("%d", &(dodaj->tab[dodaj->LiczbaElementow]));
- dodaj->LiczbaElementow++;
- }
- void rew(struct struktura* odwroc)
- {
- int i=0;
- int min;
- int max;
- scanf("%d %d", min, max);
- for(i=min-1; i<min-1+(max-min)/2 ; i++)
- {
- int tmp = odwroc->tab[i];
- odwroc->tab[i] = odwroc->tab[max-i-1];
- odwroc->tab[max-i] = tmp;
- }
- }
- void sho(struct struktura* pokaz)
- {
- int i=0;
- for(i=0; i<pokaz->LiczbaElementow; i++)
- {
- printf("%d, " ,pokaz->tab[i]);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement