救命啊!POJ3438题总也过不了!!!!!!!!!帮我看看!
北大poj3438题怎么都过不了!感觉很正确!试过的测试数据都很正确!为何??????#include<iostream>usingnamespacestd;intmai...
北大poj3438题怎么都过不了!感觉很正确!试过的测试数据都很正确!为何??????
#include<iostream>
using namespace std;
int main()
{
int testcase = 0;//测试组数
cin >> testcase;
int m = 0;
char str[1100] = " ";
for(m = 0; m < testcase; m++)
{
cin >> str;//用户输入的字符串
int i = 1;
int answer[1002] = {0};
int t = 0;
int sign = 1;
while(i < (strlen(str) + 1))
{
if(str[i - 1] != str[i])
{
answer[++t] = sign;
answer[++t] = str[i - 1] - '0';
sign = 0;
}
i++;
sign++;
}
i = 1;
while(i <= t)
{
cout << answer[i];
i++;
}
cout << endl;
}
return 0;
} 展开
#include<iostream>
using namespace std;
int main()
{
int testcase = 0;//测试组数
cin >> testcase;
int m = 0;
char str[1100] = " ";
for(m = 0; m < testcase; m++)
{
cin >> str;//用户输入的字符串
int i = 1;
int answer[1002] = {0};
int t = 0;
int sign = 1;
while(i < (strlen(str) + 1))
{
if(str[i - 1] != str[i])
{
answer[++t] = sign;
answer[++t] = str[i - 1] - '0';
sign = 0;
}
i++;
sign++;
}
i = 1;
while(i <= t)
{
cout << answer[i];
i++;
}
cout << endl;
}
return 0;
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询