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

Compiler report

input/code.cpp:17:11: error: '::main' must return 'int'
 void main() {
           ^
input/code.cpp: In function 'int main()':
input/code.cpp:33:41: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (int i = 0; i < merkkijono.length(); i++) {
                                         ^
input/code.cpp:51:17: warning: ignoring return value of 'int system(const char*)', declared with attribute warn_unused_result [-Wunused-result]
  system("pause");
                 ^

Code

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

using namespace std;

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


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

	cin >> merkkijono;

	string tulos = "";

	while (merkkijono.length() > 0) {
		int maara = atoi(merkkijono.c_str());
		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());

		for (int i = 0; i < maara; i++) {
			tulos.append(merkit);
		}
	}

	cout << tulos;

	system("pause");
}