- UID
- 4225
- 帖子
- 108
- 积分
- 7471
- 阅读权限
- 60
- 注册时间
- 2005-8-24
- 最后登录
- 2015-3-28
- 在线时间
- 1597 小时
|
#include <iostream>
#include <string>
#include <sstream>
using namespace std;
string getnextnumber(string number)
{
string rs;
int count = 0;
string::iterator it = number.begin(), ia = it;
for(; it != number.end(); it++)
{
if(*it == *ia)
++count;
else
{
ostringstream s1;
ostringstream s2;
s1 << count;
rs += s1.str();
s2 << *ia;
rs += s2.str();
ia = it;
count = 1;
}
}
ostringstream s1;
ostringstream s2;
s1 << count;
rs += s1.str();
s2 << *ia;
rs += s2.str();
return rs;
}
string makenumber(int n)
{
string rs("1");
for(int i = 0; i < n - 1; i++)
{
rs = getnextnumber(rs);
}
return rs;
}
int main()
{
cout << makenumber(8) << endl;
return 0;
} |
|