Cod sursă (job #819620)

Utilizator avatar serban-paul Serban Paul-Gabriel serban-paul IP ascuns
Problemă Beculețe (clasele 9-10) Compilator cpp-32 | 1,56 kb
Rundă Arhiva de probleme Status evaluat
Dată 9 apr. 2025 10:29:19 Scor 0
#include <fstream>

using namespace std;

ifstream fin("tanc.in");
ofstream fout("tanc.out");

struct coord{
    int i, j;
};

void c1() {
    int n, m, s, h;
    fin >> s >> m >> n >> h;
    fin.get();
    for (int i = 0; i < s; i++) {
        for (int j = 0; j < m * m; j++) {
            char x;
            fin >> x;
        }
        fin.get();
    }
    char x;
    coord c = {0, 0};
    while (fin >> x) {
        switch (x) {
        case 'N':
            c.i -= m;
            break;
        case 'S':
            c.i += m;
            break;
        case 'V':
            c.j -= m;
            break;
        case 'E':
            c.j += m;
            break;
        }
    }
    fout << c.i + 1 << ' ' << c.j + 1;
}

struct senila {
    int a[105][105];
};

senila a[15];

void c2() {
    int n, m, s, h;
    fin >> s >> m >> n >> h;
    fin.get();
    for (int i = 0; i < s; i++) {
        for (int j = 0; j < m * m; j++) {
            char x;
            fin >> x;
        }
        fin.get();
    }
    char x;
    coord c = {0, 0};
    while (fin >> x) {
        switch (x) {
        case 'N':
            c.i -= m;
            break;
        case 'S':
            c.i += m;
            break;
        case 'V':
            c.j -= m;
            break;
        case 'E':
            c.j += m;
            break;
        }
    }
    fout << c.i + 1 << ' ' << c.j + 1;
}

int main()
{
    int c;
    fin >> c;
    switch (c) {
    case 1:
        c1();
        break;
    }
    return 0;
}