Guest User

Untitled

a guest
Mar 18th, 2018
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include <iostream>
  3. using namespace std;
  4. //
  5. //int add(int x, int y)
  6. //{
  7. // int c = x + y;
  8. // return c;
  9. //}
  10. //
  11. //void swap2(int* x, int* y)
  12. //{
  13. // int c = *x;
  14. // *x = *y;
  15. // *y = c;
  16. //}
  17.  
  18. int main()
  19. {
  20. int input = 0;
  21.  
  22.  
  23. int stack[10];
  24. int pos = -1; // 배열에 값이 없을 시에 삭제 방지.
  25. while (input != 3)
  26. {
  27. cout << "선택하세요" << endl << " 1. 추가" << " 2. 삭제" << " 3. 출력" << " 4. 종료 " << endl;
  28. cin >> input;
  29. if (input == 1)
  30. {
  31. if (pos <= 9) // 배열의 길이.
  32. {
  33. cout << "stack " << " 추가합니다." << endl;
  34. pos++;
  35. cin >> stack[pos];
  36. }
  37.  
  38.  
  39. }
  40. else if (input == 2)
  41. {
  42. if (pos >= 0) // 배열의 값 유무 판단.
  43. {
  44. cout << "stack " << stack[pos] << endl;
  45. pos--;
  46. }
  47. else
  48. {
  49.  
  50. }
  51.  
  52. }
  53.  
  54.  
  55. }
  56.  
  57.  
  58.  
  59.  
  60.  
  61. return 0;
  62. }
  63.  
  64.  
  65.  
  66.  
  67.  
  68. //int a = 100;
  69. //int b = 200;
  70. //swap2(&a, &b);
  71.  
  72. //cout << a << endl << b << endl;
  73. //int a = 50;
  74. //int i = 150;
  75. //int*b = &a;
  76. //*b = 100;
  77. //
  78. //b = &i;
  79. //*b = 1500;
  80.  
  81. //cout << a << endl << i;
Add Comment
Please, Sign In to add comment