#include <string>
#include <iostream>
#include <sstream>
using namespace std;
string CountAndSay(string s)
{
if (s.size() <= 0)return "";
stringstream sout;
int count = 1;
char ch = s[0];
for (size_t i = 1; i < s.size(); ++i)
{
if (s[i] == ch)
++count;
else
{
sout << count << ch;
count = 1;
ch = s[i];
}
}
sout << count << ch;
return sout.str();
}
string CountAndSay(int n)
{
string s = "1";
while(--n > 0)
s = CountAndSay(s);
return s;
}
int main(int argc, char** argv)
{
cout << CountAndSay(1) << '\n';
cout << CountAndSay(5) << '\n';
cout << CountAndSay(7) << '\n';
return 0;
}