做了三个题,然后拖走上课去了……我的Q币 其实仔细看看自己水平之内的话可以5AC的。
Description
Jiangshan and Zhao Yiran is a sweetheart lover in different class. So, Jiangshan developed a application to send message to Zhao Yiran through wireless. However, so unfortunately, their teachers are so great that all they send will be received by their teachers too. In order to keep their message secrecy, they have to encrypt the message.
When a char X appear n times, Jiangshan will show it as Xn, for example bb->b2. In order to get the love message, Zhao Yiran have to deciphering the message with mind acts upon mind. Could you help they to deciphering.
Input
A string S, indicates the message Zhao Yiran get, all the char is lower case. There may be several test cases in the input file and end when S equal to XXX.
Output
Sample Input
a3 go12gle XXX
Sample Output
aaa goooooooooooogle
现场居然没AC,ORZ:
#include <iostream>
#include <string>
#include <ctype.h>
#include <stdlib.h>
using namespace std;
int cun(int n)
{
if(n<10)
return 1;
return cun(n%10)+1;
}
int main()
{
string inner;
while(cin>>inner && inner!="XXX")
{
int i;
for(i=0;i<inner.size();i++)
{
if(islower(inner[i]))
cout<<inner[i];
else
{
string loop;
char p;
p=inner[i-1];
for(int j=i;j<inner.size();j++)
{
if(isdigit(inner[j]))
{
loop+=inner[j];//如果用loop[j-i]的话会出问题,典例若:a10b5.B的数量会异常增高
//这个是STRING的缓冲区漏洞
}
else
break;
}
int dw=0;
dw=atoi(loop.c_str());
for(int t=0;t<dw-1;t++)
{
cout<<p;
}
i=(i+cun(dw)-1);
}
}
cout<<endl;
}
return 0;
}