fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. #define tam 3
  5.  
  6. struct pilha{
  7. int topo;
  8. int num[tam];
  9. };
  10.  
  11.  
  12.  
  13. pilha push(int num, pilha p1){
  14.  
  15. p1.topo++;
  16. p1.num[p1.topo] = num;
  17. }
  18.  
  19. void exibir(pilha p1){
  20. for(int i = 0; i <= p1.topo; i++){
  21. cout << p1.num[i] << " posicao " << i;
  22. }
  23. }
  24.  
  25. int main() {
  26. // your code goes here
  27.  
  28. int num = 0;
  29. pilha p1;
  30. p1.topo = 0;
  31.  
  32.  
  33. p1 = push(5,p1);
  34.  
  35.  
  36.  
  37.  
  38. exibir(p1);
  39.  
  40.  
  41.  
  42. return 0;
  43. }
Success #stdin #stdout 0s 16064KB
stdin
Standard input is empty
stdout
0 posicao 0