diff options
author | Rasmus Luha <rasmus.luha@gmail.com> | 2022-10-22 02:45:34 +0300 |
---|---|---|
committer | Rasmus Luha <rasmus.luha@gmail.com> | 2022-10-22 02:45:34 +0300 |
commit | fcb9ff2b96de6989e9a676e96753b1b1279acf67 (patch) | |
tree | e9a8839939aac6eeba3dea89ca0c20ad8268150e /src/main.c | |
parent | a97b362e6a35be4575f7ded3c31cdeede89ab2a8 (diff) |
hw3 status
Diffstat (limited to 'src/main.c')
-rw-r--r-- | src/main.c | 49 |
1 files changed, 9 insertions, 40 deletions
@@ -1,45 +1,14 @@ #include <stdio.h> +#include "bfi.h" +#include "mem.h" #include "stack.h" -int main() { - int x, y, z; +int main(int argc, char *argv[]) { + if (argc != 2){ + printf("Gotta Give one Argument\n"); + return 1; + } + intepret(argv[1]); - while (1) { - scanf("%d", &x); - - // 1. Kui x==0 siis print stack. - if (x == 0){ - printf("\nPrindin stacki\n"); - stackPrint(); - break; - } - - // 2. Kui empty Push. - else if (stackIsEmpty()) - stackPush(x); - - // 3. Kui x pos. ja peeked pos: push(x). - // 4. kui x pos. aga peeked neg., y=pop() ja push(x+y). - else if (x >= 0){ - y = stackPeek(); - if (y >= 0) - stackPush(x); - - else{ - z = stackPop(); - if (x+z != 0) - stackPush(x+z); - } - } - - // 5. Kui x on neg, siis pop() - else if (x < 0) { - z = stackPop(); - if (x+z != 0) { - stackPush(x+z); - } - } - - } // While loop End - return 0; + return 0; } |