Facebook
From Scorching Baboon, 5 Years ago, written in Plain Text.
This paste is a reply to Untitled from Funky Porcupine - view diff
Embed
Download Paste or View Raw
Hits: 380
  1. /******************************************************************************
  2.  
  3.                               Online C++ Compiler.
  4.                Code, Compile, Run and Debug C++ program online.
  5. Write your code in this editor and press "Run" button to compile and execute it.
  6.  
  7. *******************************************************************************/
  8.  
  9. #include <iostream>
  10.  
  11. using namespace std;
  12.  
  13. int * stos;
  14. int rozmiar;
  15. int rozmiarAktualny;
  16. int licznik=0;
  17.  
  18.  
  19. void na_stos(int a){
  20.     if(licznik>0 && rozmiar>0 && licznik==rozmiar){
  21.         int * temp;
  22.         temp = new int[licznik+1];
  23.         temp = stos;
  24.         delete stos;
  25.         stos = new int[licznik];
  26.         stos = temp;
  27.         rozmiarAktualny = licznik;
  28.         rozmiar = licznik;
  29.         licznik++;
  30.     }
  31.     else{
  32.     stos[licznik]=a;
  33.     licznik++;
  34.     }
  35. }
  36.  
  37. void ze_stosu(){
  38.     rozmiarAktualny--;
  39. }
  40.  
  41. void tworz_stos(int a){
  42.     stos = new int[a];
  43.     rozmiarAktualny = a;
  44.     rozmiar = a;
  45. }
  46.  
  47. void czyt_stos(){
  48.     for(int i = 0; i< rozmiarAktualny;++i){
  49.         cout <<stos[i] << " ";
  50.     }
  51. }
  52.  
  53. void usun_stos(){
  54.     delete stos;
  55. }
  56. int main()
  57. {
  58.     tworz_stos(1);
  59.     na_stos(5);
  60.    
  61.     czyt_stos();
  62.     cout << endl;
  63.     na_stos(5);
  64.     czyt_stos();
  65.     ze_stosu();
  66.     cout << endl;
  67.     czyt_stos();
  68.     return 0;
  69. }
  70.