Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define _CRT_SECURE_NO_WARNINGS
- #include <stdlib.h>
- #include <stdio.h>
- int stiva[100];
- int top = -1;
- void Push(int elem) {
- stiva[++top] = elem;
- }
- int Pop() {
- return stiva[top--];
- }
- int main() {
- int x = 0x0010;
- int y = 0xFF00;
- char opt[10];
- do {
- fgets(opt, 10, stdin);
- opt[strlen(opt) - 1] = '\0';
- if (strcmp(opt, "PUSH ^") == 0) {
- Push(x ^ y);
- }
- else if (strcmp(opt, "PUSH &") == 0) {
- Push(x & y);
- }
- else if (strcmp(opt, "PUSH |") == 0) {
- Push(x | y);
- }
- else if (strcmp(opt, "POP") == 0) {
- printf("%x\n", Pop());
- }
- else {
- exit(1);
- }
- }while (1);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement