Code Submission Evaluation System Login

Datatähti 2016 alku

Start:2015-09-28 00:00:00
End:2015-10-12 00:00:00
 

Tasks | Scoreboard | Statistics


CSES - Datatähti 2016 alku - Results
History
2015-10-04 21:56:24100
2015-10-04 21:46:0839
2015-10-04 21:44:4939
2015-10-04 21:38:4739
2015-10-04 21:38:030
2015-10-04 21:23:360
2015-10-04 21:17:360
2015-10-04 18:44:2939
2015-10-04 18:43:0539
2015-10-04 18:41:4139
2015-10-04 18:40:5039
2015-10-04 18:36:4139
2015-10-04 18:35:5139
2015-10-04 18:34:580
2015-10-04 18:33:56
2015-10-04 18:32:04
2015-10-04 18:19:5039
2015-10-04 18:13:3839
2015-10-04 18:13:12
2015-10-04 18:09:5939
2015-10-04 18:03:5339
Task:Osajono
Sender:hugo-hur
Submission time:2015-10-04 18:32:04
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;
}