Advertisement
KlimexuS

Untitled

Jan 5th, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.34 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3. #define RozmiarTablicy 1000
  4.  
  5. struct struktura
  6. {
  7. int tab[RozmiarTablicy];
  8. int LiczbaElementow;
  9. int schowek[RozmiarTablicy];
  10. int LiczbaKopiowanych;
  11. }
  12. ;
  13.  
  14. void add(struct struktura* dodaj);
  15. void rew(struct struktura* odwroc, int min, int max);
  16. void sho(struct struktura* pokaz);
  17.  
  18.  
  19.  
  20. int main()
  21. {
  22. struct struktura lista;
  23. lista.LiczbaElementow = 0;
  24. lista.LiczbaKopiowanych = 0;
  25.  
  26. char akcja[4];
  27. scanf ("%3s", akcja);
  28. while(1)
  29. {
  30. if(strcmp(akcja, "ext")==0)
  31. break;
  32. else if(strcmp(akcja, "add")==0)
  33. add(&lista);
  34. else if(strcmp(akcja, "sho")==0)
  35. sho(&lista);
  36. else if(strcmp(akcja, "rew")==0)
  37. int min;
  38. int max;
  39. scanf("%d %d", &min, &max);
  40. rew(&lista, min, max);
  41.  
  42.  
  43.  
  44. scanf ("%3s", akcja);
  45. }
  46.  
  47.  
  48.  
  49.  
  50. }
  51.  
  52. void add(struct struktura* dodaj)
  53. {
  54. scanf("%d", &(dodaj->tab[dodaj->LiczbaElementow]));
  55. dodaj->LiczbaElementow++;
  56. }
  57.  
  58. void rew(struct struktura* odwroc, int min, int max)
  59. {
  60. if (min >= max)
  61. return;
  62. int tmp = odwroc->tab[min - 1];
  63. odwroc->tab[min - 1] = odwroc->tab[max-1];
  64. odwroc->tab[max - 1] = tmp;
  65. rew(odwroc, ++min, --max);
  66. }
  67.  
  68. void sho(struct struktura* pokaz)
  69. {
  70. static int=0;
  71. int i=0;
  72. if(i>=->LiczbaElementow)
  73. {
  74. i=0;
  75. return;
  76. }
  77. else
  78. printf("%d, " ,pokaz->tab[i]);
  79. sho(pokaz);
  80.  
  81. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement