Home > Back-end >  School test site appears the runtime error, and no problem on devc, humble
School test site appears the runtime error, and no problem on devc, humble

Time:11-06

Topic is, after deleting the same element of array element, with a space between number and ensure the consistency of the first appearance of each element of the sequence, but at runtime runtime error, array is not too big, check for many times, also didn't find any small mistake
The Sample Input
10
1 1 1 1 1 1 2 2 2 2

The Sample Output
1
2



#include

Int main () {
Int n, I, j, a [100], [100] b, w, count, p=0;
The scanf (" % d ", & amp; n);
for(i=0; iThe scanf (" % d ", & amp; A [I]);
for(i=0; icount=0;
For (j=I + 1; jIf (a==[I] a [j])
count++;
}
If (count==0)
B=[p++] a [I];
}
for(i=0; iPrintf (" % d, b [I]);
return 0;
}

CodePudding user response:

Please look at the question clearly, ensure the first appearance of each element of the sequence of consistency, so in some cases, this algorithm can't satisfy you

CodePudding user response:

Try array into 100 w

CodePudding user response:

Can use the STD: : set:

#include
#include

Int main ()
{
Int n, x;
STD: : set s;

The scanf (" % d ", & amp; n);
While (n -)
{
The scanf (" % d ", & amp; X);
Auto r=s.i nsert (x);
If (r.f first!=s.e nd () & amp; & * r.f irst==x & amp; & R.s econd)
Printf (" % d % s ", x, n? "" :" ");
}
Puts (" ");

return 0;
}