Untitled
unknown
c_cpp
3 years ago
848 B
7
Indexable
#include <bits/stdc++.h>
using namespace std;
#define fr(i,n) for(int i = 0; i < int(n); i++)
int main()
{
ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
int t, n; cin >> t;
cin.ignore();
string s; cin >> s; int c = 0, ind, d = 0;
char freq[26] = {0};
cin.ignore();
for (size_t i = 0; i < t; i++) {
for (size_t j = i+1; j < t; j++) {
if(s[j] == s[i])c++;
else if(s[j] != s[i])
{
d += c;
i = j; cout << " j: " << j << " d: " << d << " ";
break;
}
if((s[j] == s[i]) && j == t-1)
{
d += c;
i = j; cout << " j: " << j << " d: " << d << " ";
break;
}
}
}
cout << d;
return 0;
}
Editor is loading...