UVA Solution 320 - Border - Solution in C, C++ | Volume 3 - 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 5, 2017

UVA Solution 320 - Border - Solution in C, C++ | Volume 3

UVA Solution 320 - Border - Solution in C, C++ | Volume 3


UVA Online Judge Solution 320 - Border | Volume 3
UVA Problem Link - https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=5&page=show_problem&problem=256

Problem Name: 320 - Border
Problem Number : UVA - 320 - Border
Online Judge : UVA Online Judge Solution
Volume: 3
Solution Language : C, C plus plus

UVA Solution 320 - Border - Solution in C, C++ | Volume 3


UVA Solution 320 - Border Code in C, CPP:


#include <stdio.h>

int main() {
    int t, x, y, i, j, test = 0;
    char cmd[2000];
    scanf("%d", &t);
    while(t--) {
        int map[32][32] = {};
        scanf("%d %d", &x, &y);
        scanf("%s", cmd);
        for(i = 0; cmd[i]; i++) {
            if(cmd[i] == 'E') {
                map[x][y-1] = 1;
                x++;
            }
            if(cmd[i] == 'N') {
                map[x][y] = 1;
                y++;
            }
            if(cmd[i] == 'W') {
                map[x-1][y] = 1;
                x--;
            }
            if(cmd[i] == 'S') {
                map[x-1][y-1] = 1;
                y--;
            }
        }
        printf("Bitmap #%d\n", ++test);
        for(i = 31; i >= 0; i--) {
            for(j = 0; j < 32; j++) {
                putchar(map[j][i] ? 'X' : '.');
            }
            puts("");
        }
        puts("");
    }
    return 0;
}

No comments:

Post a Comment