Ser1ousSAM

look and tell

Sep 11th, 2020 (edited)
72
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <vector>
  3. #include <string>
  4. using namespace std;
  5. int main()
  6. {
  7.     int k, i, j, num;
  8.     string S, T;
  9.     cin >> k;
  10.     S = '1';
  11.     for (int num = 0; num < k-1; num++) {
  12.         T = "";
  13.         i = 0;
  14.         while (i < S.size()) {
  15.             j = 1;
  16.             while (i+1 < S.size() && (S[i + 1]==S[i])) {
  17.                 j++;
  18.                 i++;
  19.             }
  20.             T += to_string(j) + S[i];
  21.             i++;
  22.         }
  23.         S = T;
  24.     }
  25.     cout << S;
  26.     return 0;
  27. }
RAW Paste Data