HOJ 1020
来源:互联网 发布:如何防范sql注入式攻击 编辑:程序博客网 时间:2024/05/22 08:11
#include<iostream>
#include<string>
#include<sstream>
using namespace std;
int main()
{
int n;
cin >> n;
while (n--)
{
string str;
string temp;
cin >> str;
int len = str.length();
temp += str[len-1];
int count = 1;
for (int i = len-2; i >=0; i--)
{
if (str[i] != str[i +1 ])
{
if (count != 1)
{
ostringstream s1;
s1 << count;
string s2 = s1.str();
for (int k = s2.length() - 1; k >= 0;k--)
temp += s2[k];
s1.clear();
}
temp += str[i];
count = 1;
}
else
{
count++;
}
}
if (count != 1)
{
ostringstream s2;
s2<< count;
string s3 = s2.str();
for (int k = s3.length() - 1; k >= 0; k--)
temp += s3[k];
s2.clear();
}
int size = temp.length();
for (int j = size-1; j >= 0; j--)
{
cout << temp[j];
}
cout << endl;
}
return 0;
}
#include<string>
#include<sstream>
using namespace std;
int main()
{
int n;
cin >> n;
while (n--)
{
string str;
string temp;
cin >> str;
int len = str.length();
temp += str[len-1];
int count = 1;
for (int i = len-2; i >=0; i--)
{
if (str[i] != str[i +1 ])
{
if (count != 1)
{
ostringstream s1;
s1 << count;
string s2 = s1.str();
for (int k = s2.length() - 1; k >= 0;k--)
temp += s2[k];
s1.clear();
}
temp += str[i];
count = 1;
}
else
{
count++;
}
}
if (count != 1)
{
ostringstream s2;
s2<< count;
string s3 = s2.str();
for (int k = s3.length() - 1; k >= 0; k--)
temp += s3[k];
s2.clear();
}
int size = temp.length();
for (int j = size-1; j >= 0; j--)
{
cout << temp[j];
}
cout << endl;
}
return 0;
}
0 0
- HOJ 1020
- HOJ 1020
- HOJ
- Hoj 1020 Afshung Pizza Delivery
- HOJ 1004
- 位图-hoj
- HOJ Megaminx
- hoj WERTYU
- hoj 12033
- HOJ-2277
- HOJ-1962
- hoj 1408
- hoj 1006
- hoj 1138
- hoj 1999
- hoj(1797)
- Hoj 2012
- hoj 1556
- ListView的使用技巧集合(五)
- 山东省第七届ACM省赛------Reversed Words
- [LeetCode]problem 60. Permutation Sequence
- E
- Exchange 2010 PS 之 Get-MessageTracking命令!
- HOJ 1020
- 【笔记】投影坐标到屏幕坐标
- SICP 习题2.21 square-list
- 文章标题
- 动态维护数列的中位数
- 进程、线程和协程的区别是什么
- 在jsp中设置cookie
- PHP对表单提交特殊字符的过滤和处理
- test