0
Why
I wanna if I input such as 1224, and it output 124.(I mean if a integer appear twice,Only output once!)But I input 1 2 2 4,it out 122486016??? Anyone helps me to find which part went wrong? Thx https://code.sololearn.com/cQXMV53KGOfK/?ref=app
5 Answers
+ 2
I realized a mistake in all for loop, you start I and K with 0 and in the conditional you put <=N.
If you count the times that the for "works" you'll realize that the code runs different of what you are looking. For example if n=2, for(int i=0; I<=n;I++;) , the for will run one time and the value of I will be 1, it will run again and I will be 2 and how i==n is true the for will run again.
0
no I input 4
1 2 2 4
0
The best way to create you array is get the value of n and then declare the array. Like this:
int n = 0;
scanf("%d", &n);
int s[n];
0
I find your error, it's in the if(s[I] != s[k])k++;
At least on my solution code.
How you are inside a for loop, In the end of the code block the variable k will be incremented so you double increment k and skip one code verification. Look my profile and open the public code named answerToWhy, there i solve your problem in my way.