Task: | Osajono |
Sender: | Pohjantahti |
Submission time: | 2017-06-23 23:33:48 +0300 |
Language: | C++ |
Status: | COMPILE ERROR |
Compiler report
input/code.cpp: In function 'int main()': input/code.cpp:12:29: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] for(int i = 0; i < s.length(); ++i) { ^ input/code.cpp:15:23: error: invalid use of member function (did you forget the '()' ?) for (int i = 0; i < s.length; ++i) { ^
Code
#include <iostream>#include <string>using namespace std;string s;int cnt[30];int res;int main() {cin>>s;for(int i = 0; i < s.length(); ++i) {cnt[s[i]-'A']++;}for (int i = 0; i < s.length; ++i) {res += cnt[i] + cnt[i]*(cnt[i]-1)/2;}cout<<res<<"\n";}