Created
February 28, 2015 14:05
-
-
Save ik11235/8bc571cf897642d98626 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(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