Advertisement
KlimexuS

Untitled

Jan 5th, 2018
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.23 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);
  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. rew(&lista);
  38.  
  39.  
  40. scanf ("%3s", akcja);
  41. }
  42.  
  43.  
  44.  
  45.  
  46. }
  47.  
  48. void add(struct struktura* dodaj)
  49. {
  50. scanf("%d", &(dodaj->tab[dodaj->LiczbaElementow]));
  51. dodaj->LiczbaElementow++;
  52. }
  53.  
  54. void rew(struct struktura* odwroc)
  55. {
  56. int i=0;
  57. int min;
  58. int max;
  59.  
  60.  
  61. scanf("%d %d", min, max);
  62. for(i=min-1; i<min-1+(max-min)/2 ; i++)
  63. {
  64. int tmp = odwroc->tab[i];
  65. odwroc->tab[i] = odwroc->tab[max-i-1];
  66. odwroc->tab[max-i] = tmp;
  67.  
  68. }
  69.  
  70. }
  71. void sho(struct struktura* pokaz)
  72. {
  73. int i=0;
  74. for(i=0; i<pokaz->LiczbaElementow; i++)
  75. {
  76. printf("%d, " ,pokaz->tab[i]);
  77. }
  78.  
  79. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement