Rezultati

Up. imeNalogaJezikRezultatČas oddaje
ayy-2018 Tabela C++ 100/100OK 13. okt '18 @ 11:31

Test Točke Porabljen spomin Porabljen čas Status
#1 20/20 3,965 MiB 0,102 s OK
#2 20/20 3,203 MiB 0,001 s OK
#3 20/20 3,055 MiB 0,000 s OK
#4 20/20 3,039 MiB 0,000 s OK
#5 20/20 3,250 MiB 0,000 s OK

Ocenjevani program (main.cpp):
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;


int main() {
    int R, C;
    cin >> R >> C;

    string align;
    cin >> align;

    vector<vector<string>> input;
    vector<int> column;

    while (R--) {
        vector<string> tmp;
        string str;
        cin.get();

        for (int i = 0; i < C-1; i++) {
            getline(cin, str, ',');
            tmp.push_back(str);
        }

        cin >> str;
        tmp.push_back(str);
        input.push_back(tmp);
    }

    for (int j = 0; j < input[0].size(); j++) {
        int max = 0;
        for (int i = 0; i < input.size(); i++) {
            if (input[i][j].size() > max) {
                max = input[i][j].size();
            }
        }
        column.push_back(max);
    }


    for (int i = 0; i < input.size(); i++) {
        for (int j = 0; j < input[i].size(); j++) {
            if (align[j] == 'R') {
                for (int k = 0; k < column[j] - input[i][j].size(); k++) {
                    cout << " ";
                }
                cout << input[i][j];
            } else {
                cout << input[i][j];
                for (int k = 0; k < column[j] - input[i][j].size(); k++) {
                    cout << " ";
                }
            }

            if (j < input[i].size() - 1) {
                cout << " | ";
            }
        }

        cout << endl;
    }



    return 0;
}