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:13:12
Language:C++
Status:COMPILE ERROR

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:12:22: error: invalid conversion from 'const char*' to 'char*' [-fpermissive]
  char* str = s.c_str();
                      ^

Code

#include <iostream>
#include <string>
using namespace std;
int main() {
	std::cin.sync_with_stdio(false);//Faster execution
	unsigned int osajonot = 0;
	string s;
	cin >> s;
	//First iterate over all single characters -> ensimmäisenKategorian osajonojen määrä on merkkijonon pituus
	unsigned int strLen = s.size();
	osajonot += strLen;
	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; i++){
			if(/*s.at(i)*/str[i] == atStart){
				osajonot++;
			}
		}
	}
	cout << osajonot << std::endl;
	return 0;
}