Same code working in C++, but not in C

Hi,

I was solving a practice problem, and came across this strange issue where the exact same piece of code is giving me a correct answer in C++, but a Wrong Answer in C. Why is that so? There are no compile errors, and the sample input is working in both C and C++ correctly. I must be missing a behavior change between these 2 languages.

My guess is maybe the passing of arrays? But if I am printing the sorted array, it is being sorted correctly in both cases. Any help here would be much appreciated.

Correct submission in C++:
http://www.codechef.com/viewsolution/6708439

Wrong Answer submission in C:
http://www.codechef.com/viewsolution/6708447

1 Like