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, int min, int max);
- 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)
- int min;
- int max;
- scanf("%d %d", &min, &max);
- rew(&lista, min, max);
- scanf ("%3s", akcja);
- }
- }
- void add(struct struktura* dodaj)
- {
- scanf("%d", &(dodaj->tab[dodaj->LiczbaElementow]));
- dodaj->LiczbaElementow++;
- }
- void rew(struct struktura* odwroc, int min, int max)
- {
- if (min >= max)
- return;
- int tmp = odwroc->tab[min - 1];
- odwroc->tab[min - 1] = odwroc->tab[max-1];
- odwroc->tab[max - 1] = tmp;
- rew(odwroc, ++min, --max);
- }
- void sho(struct struktura* pokaz)
- {
- static int=0;
- int i=0;
- if(i>=->LiczbaElementow)
- {
- i=0;
- return;
- }
- else
- printf("%d, " ,pokaz->tab[i]);
- sho(pokaz);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement