CSES - Putka Open 2015 – 1/6 - Results
Submission details
Task:Aita
Sender:
Submission time:2015-07-18 16:58:04 +0300
Language:C++
Status:COMPILE ERROR

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:26:25: error: expected initializer before '+=' token
                 int num += aita.at(i);
                         ^
input/code.cpp:27:37: error: 'num' was not declared in this scope
                 char *intStr = itoa(num);
                                     ^
input/code.cpp:27:40: error: 'itoa' was not declared in this scope
                 char *intStr = itoa(num);
                                        ^

Code

#include <iostream>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

int main() {
    int n, k;
     cin >> n >> k;

    vector<int> aita;
        for (int i = 1; i < n + 1; i+= 2) {
            aita.push_back(i);
        }

        for (int i = 2; i < n + 1; i+= 2) {
            aita.push_back(i);
        }

        if (n != 2) {
                string test ="";
            for (int i = 0; i < n; i++) {
                int num += aita.at(i);
                char *intStr = itoa(num);
                string str = string(intStr);
                test = test + str;
        }
        cout << test;
        } else {
           cout << "QAQ";
        }
}