网易互娱第一题A-Z
自测的时候,输出和测试样例一模一样,为什么还不通过?求大佬指点
#include<iostream>
#include<string>using namespace std;
int main()
{
string str[100];
int T;
cin >> T;
for(int t=0;t<T;t++)
{
cin >> str[t];
}
int len;
int M=1;
int last;
for(int i=0;i<T;i++)
{
len=str[i].size();
if(len<=0 || len>50000)
break;
cout<<str[i][0];
for(int j=1;j<len;j++)
{
while(str[i][j]-str[i][j-1]==1)
{
j++;
M++;
}
if(M>=4)
{
cout<<"-"<<str[i][j-1];
M=1;
}
else if(M==2 || M==3)
{
for(int k=j-M+1;k<j;k++)
cout<<str[i][k];
M=1;
}
cout<<str[i][j];
}
cout<<endl;
}
}
#网易互娱##笔试题目##秋招##网易#