#include <stdio.h>
int main(void) {
int a[5]={1,2,0,5,4},i,j,c;
for(i=0;i<5;i++)
{
for(j=0;j<5-i;j++){
if(a[j]>a[j+1])
{
c=a[j];
a[j]=a[j+1];
a[j+1]=c;
}
}
}
for(i=0;i<5;i++)
{
printf("%d",a[i]);
}
return 0;
}
ideone says "Time limit exceeded time: 5 memory: 2048 signal:24"
but it works fine on turbo compiler
a[j+1]
is array out of bound access which will lead to undefined behavior