Water problem, a younger brother for the first time, a great god help check code, why is the AC not,,, the feeling is already considering all things
#include
#include
#include
#include
using namespace std;
Void the BubbleSort (long long * pData, int count)
{
Long long temp.
For (int I=1; I & lt; The count. I++)
{
For (int j=count - 1; J & gt;=I; J -)
{
If (pData [j]
Temp=pData [j - 1);
PData [1]=pData [j];
PData [j]=temp;
}
}
}
}
//all the conditions listed below:
//(1) input the Numbers 5 and there are a number of ends in 5
//(2) none of the Numbers 5, a total of only a number
//(3) input the Numbers and the last is not 5
//(4) the first number input Numbers is 5
//(5) input digital sequence 5
//between them also can be combined each other
Int main ()
{
String s;
int i=0;
int j=0;
While (cin> S)
{
Int n=s.l ength ();
Char * c=new char [n].
Char * f=new char [n].
int count=0;
//length () function to until the first space, record is an effective length of the string (at the end)
for(i=0; I
While (s [I]=='5')//processing continuous 5
{
C [I]=' ';
F [I]=' ';
i++;
}
If (c [I - 1]==' ')//that the count in five consecutive records only a 5, namely the count + 1
{
count++;
C [, I]='1';
continue;//out of this layer for loop
}
C [I] [I]=s;//otherwise do one-to-one assignment
F [I] [I]=s;
}//end of the cycle, intermediate arrays c just to record the number of 5,
//target array, the content of the string s and f all turn into 5 Spaces
//count the actual record is five a set number of
If ((f [0]!=' ') & amp; & (f (n - 1)!=' ') & amp; & (count! Count++=0));//fore and aft is 5, but there are 5 among
If (count==0) count=1;//no 5, only a numeric string does not contain 5
If ((f [0]==' ') & amp; & (f (n - 1)==")) count -;//fore and aft all 5
//after the above processing, the count is actually become the original Numbers were separated into a number of substring
//for (I=0; I
Char * * ch=new char * (count);
for(i=0; I
//need to be separated by Spaces in an array of f strings are stored in an array of ch
Int k=0;//character assignment start the starting point of the
for(i=0; F [I]==' '; I++)
K++;
//the original Numbers for several 5, assignment should skip these five characters
for(i=0; I
{
If (k
If (f [k]==' ')
//as a matter of fact, when the first number is 5, this just skip the first number string, in the first 5 is applicable when the Numbers are not
{
K++;
While (f [k]==' ')
K++;
break;
//out of the for loop, also jump over a number of Spaces in f [] to complete this line string input
}
The else//f [k]!
=' 'Ch [I] [j]=f [k++];
}
}
Long long * stringtoint=new long long (count);
for(i=0; I
The BubbleSort (stringtoint, count);
for(i=0; I
If (i
Cout
}
return 0;
}
CodePudding user response:
Subject toProblem Description
Input line Numbers, if we put the '5' in this column of figures as Spaces, then get a line of some nonnegative integers separated with a space (there may be some integer begin with '0', the head of the '0' should be ignored, unless this integer is composed of a number of '0', when the integer is 0),
Your mission is: to the segmentation of integers, output according to the order of growing up,
Input
Input contains multiple test cases, each group of input data is only a line number (no Spaces between Numbers), the length of this column of figures is not more than 1000,
Input data to guarantee: segmentation of nonnegative integer not greater than 100000000; Input data cannot be fully composed of '5',
The Output
For each test case, the output segmentation integer sorting results, the adjacent two integers, separated by a space between each set of output a line,
The Sample Input
0051231232050775
The Sample Output
0 77 12312320