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

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:13:44: error: 'strlen' was not declared in this scope
  unsigned int strLen = (unsigned)strlen(str);//s.size();
                                            ^

Code

#include <iostream>
#include <string>
#include <stdio.h>
using namespace std;
int main() {
	std::cin.sync_with_stdio(false);//Faster execution
	//unsigned int osajonot = 0;
	//string s = "";
	char str[10000];
	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 = (unsigned)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;
}