CSES - Datatähti 2016 alku - Results
Submission details
Task:Osajono
Sender:hugo-hur
Submission time:2015-10-04 18:32:04 +0300
Language:C++
Status:COMPILE ERROR

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:8:6: error: expected unqualified-id before '[' token
  char[10000] str;
      ^
input/code.cpp:9:14: error: 'str' was not declared in this scope
  cin.getline(str, 10000);//Gets the line entered and moves it to string
              ^
input/code.cpp:12:34: error: 'strlen' was not declared in this scope
  unsigned int strLen = strlen(str);//s.size();
                                  ^

Code

#include <iostream>
#include <string>
using namespace std;
int main() {
	std::cin.sync_with_stdio(false);//Faster execution
	//unsigned int osajonot = 0;
	//string s = "";
	char[10000] str;
	cin.getline(str, 10000);//Gets the line entered and moves it to string
	//cin >> s;
	//First iterate over all single characters -> ensimmäisenKategorian osajonojen määrä on merkkijonon pituus
	unsigned int strLen = strlen(str);//s.size();
	unsigned int osajonot = strLen;
	//const char* str = s.c_str();
	//Jaa osajonoihin, joissa ensimmäinen ja viimeinen kirjain ovat samat
	//Iteroi merkkijonoa
	for(unsigned int startIndex = 0; startIndex < (strLen - 1); startIndex++){
		//char atStart = str[startIndex];//s.at(startIndex);
		for(unsigned int i = startIndex + 1; i != (strLen - 1); i++){
			if(/*s.at(i)*/str[i] == str[startIndex]){
				osajonot++;
			}
		}
	}
	cout << osajonot << std::endl;
	return 0;
}