UVA Solution 448 - OOPS - Solution in C, C++ - Online Judge Solution

Latest

It is a free Online judges problems solution list. Here you can find UVA online Judge Solution, URI Online Judge Solution, Code Marshal Online Judge Solution, Spoz Online Judge Problems Solution

Friday, May 12, 2017

UVA Solution 448 - OOPS - Solution in C, C++

UVA Solution 448 - OOPS - Solution in C, C++

UVA Online Judge Solution 448 - OOPS | Volume 4
UVA Problem Link - 448 - OOPS - https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=6&page=show_problem&problem=389

Problem Name: 448 - OOPS
Problem Number : UVA - 448 - OOPS
Online Judge : UVA Online Judge Solution
Volume: 4
Solution Language : C, C plus plus

UVA Online Judge Solution, UVA OJ Solution list, UVA Problems Solution, UVA solver, UVA all problem solution list

UVA Solution 400 Code in C/CPP:

#include <stdio.h>
const int mod = 0x3fff;
int main() {
    char op[][10] =
    {"ADD","SUB","MUL","DIV","MOV","BREQ","BRLE","BRLS",
        "BRGE","BRGR","BRNE","BR","AND","OR","XOR","NOT"
    };
    char opcode[][5] =
    { "R", "$", "PC+", ""
    };
    int opN[] =
    {2,  2,  2,  2,  2,  1,  1,  1,
        1,  1,  1,  1,  3,  3,  3,  1
    };
    char buf[500000], *p = buf;
    int opnum, i;
    while(scanf("%s", p) == 1) {
        while(*p)   p++;
    }
    p = buf;
    while(*p) {
        sscanf(p, "%1X", &opnum), p++;
        printf("%s ", op[opnum]);
        for(i = 0; i < opN[opnum]; i++) {
            if(i)   putchar(',');
            int code;
            sscanf(p, "%4X", &code);
            p += 4;
            printf("%s%d", opcode[code/(mod+1)], code&mod);
        }
        puts("");
    }
    return 0;
}


Tags: UVA Online Judge Solution, UVA OJ Solution list, UVA Problems Solution, UVA solver, UVA all problem solution list, UVA OOPS  code in C, UVA 448 code in C++, UVA OOPS solution in C, UVA 448 solution

No comments:

Post a Comment