Count and Say
class Solution {
public:
string countAndSay(int n) {
string ret = "1";
string Tempret;
int count1,i;
char read;
while(--n)
{
count1 = 0;
read = ret[0];
Tempret.clear();
for(i = 0;i<ret.size();i++)
{
if(ret[i] == read)
{
count1 ++;
}
else
{
Tempret.push_back(count1+'0');
Tempret.push_back(read);
count1 = 1;
read = ret[i];
}
}
if(i == ret.size())
{
Tempret.push_back(count1+'0');
Tempret.push_back(read);
}
ret = Tempret;
}
return ret;
}
};