Skip to content

Instantly share code, notes, and snippets.

@ik11235
Created February 28, 2015 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ik11235/8bc571cf897642d98626 to your computer and use it in GitHub Desktop.
Save ik11235/8bc571cf897642d98626 to your computer and use it in GitHub Desktop.
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char *argv[])
{
string s;
cin>>s;
string ans;
char tmp=s[0];
int cnt=1;
for(int i=1;i<=s.size();i++)
{
if(i==s.size() || tmp!=s[i])
{
ans+=tmp;
ans+=to_string(cnt);
if(i<s.size())
{
tmp=s[i];
cnt=1;
}
}
else
cnt++;
}
cout<<ans<<endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment