fork download
  1. #include <stdio.h>
  2. #define SIZE 5
  3. double stack[SIZE];
  4. int sp;//ポインタ
  5.  
  6. void push(double x){
  7. if(sp>=SIZE){
  8. printf("満タン\n");
  9. }else{
  10. stack[sp]=x;
  11. sp++;
  12. }
  13. }
  14.  
  15. double pop(void){
  16. if(sp<=0){
  17. printf("空\n");
  18. return 0;
  19. }else{
  20. return stack[--sp];
  21. }
  22. }
  23.  
  24. int main(void) {
  25.  
  26. double c1,c2;
  27. push(1);
  28. push(2);
  29. //+
  30. c2=pop();
  31. c1=pop();
  32. printf("%lf+%lf=",c1,c2);
  33. push(c1+c2);
  34. printf("%lf",pop());
  35. return 0;
  36. }
  37.  
Success #stdin #stdout 0s 5308KB
stdin
Standard input is empty
stdout
1.000000+2.000000=3.000000