Advertisement
Brick99

2018 RLE

May 20th, 2018
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.65 KB | None | 0 0
  1. /* https://www.rpz-rs.org/648/rpz-rs/Takmicarski/zadaci/iz/informatike/za/srednju/skolu,/skolska/2018./godina#.WwGAlC5uaM8 */
  2.  
  3. #include <iostream>
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9.     int tests;
  10.     cin>>tests;
  11.  
  12.     string g;
  13.     getline(cin,g,'\n');
  14.  
  15.     while (tests--)
  16.     {
  17.         getline(cin,g,'\n');
  18.  
  19.         char a = g[0];
  20.         int br = 1;
  21.  
  22.         for (int i=1;i<g.size();i++)
  23.         {
  24.             if ( g[i] != a )
  25.             {
  26.                 cout<<br<<a;
  27.                 br = 1;
  28.                 a=g[i];
  29.             }
  30.             else br++;
  31.         }
  32.         cout<<br<<a;
  33.         cout<<endl;
  34.     }
  35.     return 0;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement