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

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:42:41: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (int i = 0; i < merkkijono.length(); i++) {
                                         ^
input/code.cpp:54:11: error: request for member 'append' in 'tulos', which is of non-class type 'char*'
     tulos.append(merkit);
           ^
input/code.cpp:58:10: error: request for member 'append' in 'tulos', which is of non-class type 'char*'
    tulos.append(merkit);
          ^

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;

	char *tulos = new char[1000000];

	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++) {
				tulos.append(merkit);
			}
		}
		else {
			tulos.append(merkit);
		}
	}

	return 0;
}