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

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:24:31: error: invalid conversion from 'char*' to 'char' [-fpermissive]
  char tulos = new char[1000000];
                               ^
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:24:7: warning: unused variable 'tulos' [-Wunused-variable]
  char tulos = new char[1000000];
       ^

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++) {
				cout << merkit;
			}
		}
		else {
			cout << merkit;
		}
	}

	return 0;
}