arrays - Time limit exceeded in bubble sort -



arrays - Time limit exceeded in bubble sort -

problem-to sort array in ascending order algorithm used-bubble sort error-time limit exceeded compiler-ideone online editor /codeblocks possible alternative this?

int a[5]; int i,t,j; for(i=0;i<=4;i++) //for initialising elements { printf("enter 5 numbers"); scanf("%d",&a[i]); } for(j=0;j<5;i++) //for sorting { for(i=0;i<5;i++) { if(a[i]>a[i+1]) { t=a[i+1]; a[i+1]=a[i]; a[i]=t; } } } for(i=0;i<=4;i++) //for printing sorted array { printf("%d\n",a[i]); }

your loop:

for(j=0;j<5;i++) //for sorting

should j++, should be

for(j=0;j<5;j++)

your sec loop:

for(i=0;i<5;i++)

should

for(i=0;i<4;i++)

arrays sorting bubble-sort

Comments

Popular posts from this blog

maven fortify plugin : Unable to load build session with ID XXXXX .. See log file for more details -

c# - Primavera WebServices does not return any data -

android - Display emoji panel with genymotion - keyboard/touch input? -