-
-
Save murilomaeda/b232bcb579ae0f0aed257a4b915fde37 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<bits/stdc++.h> | |
using namespace std; | |
int main() | |
{ | |
cin.tie(0)->sync_with_stdio(0); | |
int n; cin >> n; | |
string s; cin >> s; | |
//vamos considerar que já estamos incluindo o primeiro caractere | |
int k = 1; | |
for(int i = 1; i < s.length(); i++) | |
{ | |
if(s[i] == s[i-1]) k++; | |
if(s[i] != s[i-1]) | |
{ | |
cout << k << " " << s[i-1] << " "; | |
k = 1; | |
} | |
} | |
cout << k << " " << s[s.length() - 1]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment