CSES - Datatähti 2017 alku - Results
Submission details
Task:Pakkaus
Sender:VOL
Submission time:2016-10-04 18:56:46 +0300
Language:C++
Status:COMPILE ERROR

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:24:13: error: expected unqualified-id before '[' token
  signed char[1000000] *tulos = "";
             ^
input/code.cpp:42:41: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (int i = 0; i < merkkijono.length(); i++) {
                                         ^

Code

#include <string>
#include <iostream>
#include <vector>

using namespace std;

int numeroidenMaara(int i) {
	int numerot = 0;
	while (i) {
		i /= 10;
		numerot++;
	}
	return numerot;
}


int main() {
	string merkkijono;
	vector<int> numeroIndeksit;
	vector<int> maarat;

	cin >> merkkijono;

	signed char[1000000] *tulos = "";

	while (merkkijono.length() > 0) {
		int maara = atoi(merkkijono.c_str());

		if (maara == 0) {
			merkkijono.erase(0, 1);

			continue;
		}
		else if (maara < 0) return 0;
		else {
			int numerot = numeroidenMaara(maara);

			merkkijono.erase(0, numerot);
		}

		string merkit;
		for (int i = 0; i < merkkijono.length(); i++) {
			if (!isdigit(merkkijono.at(i))) {
				merkit += merkkijono.at(i);
			}
			else {
				break;
			}
		}

		merkkijono.erase(0, merkit.length());
		if (maara != 0) {
			for (int i = 0; i < maara; i++) {
				cout << merkit;
			}
		}
		else {
			cout << merkit;
		}
	}

	return 0;
}