Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include <iostream>
- using namespace std;
- //
- //int add(int x, int y)
- //{
- // int c = x + y;
- // return c;
- //}
- //
- //void swap2(int* x, int* y)
- //{
- // int c = *x;
- // *x = *y;
- // *y = c;
- //}
- int main()
- {
- int input = 0;
- int stack[10];
- int pos = -1; // 배열에 값이 없을 시에 삭제 방지.
- while (input != 3)
- {
- cout << "선택하세요" << endl << " 1. 추가" << " 2. 삭제" << " 3. 출력" << " 4. 종료 " << endl;
- cin >> input;
- if (input == 1)
- {
- if (pos <= 9) // 배열의 길이.
- {
- cout << "stack " << " 추가합니다." << endl;
- pos++;
- cin >> stack[pos];
- }
- }
- else if (input == 2)
- {
- if (pos >= 0) // 배열의 값 유무 판단.
- {
- cout << "stack " << stack[pos] << endl;
- pos--;
- }
- else
- {
- }
- }
- }
- return 0;
- }
- //int a = 100;
- //int b = 200;
- //swap2(&a, &b);
- //cout << a << endl << b << endl;
- //int a = 50;
- //int i = 150;
- //int*b = &a;
- //*b = 100;
- //
- //b = &i;
- //*b = 1500;
- //cout << a << endl << i;
Add Comment
Please, Sign In to add comment