-
May 27th, 2013, 01:35 PM
#1
Bubble Sort-question
Hey!!!I have a question!!!!Why at the following code,which is an implematation of the bubble sort :
#include <stdio.h>
int main()
{
int a[10]={34,2,56,78,34,5,76,10,47,29};
int n=10;
int i,j,temp;
for(i=0;i<10;i++)
{
for(j=0;j<n-i;j++)
{
if(a[j]>a[j+1])
{
temp=a[j];
a[j]=a[j+1];
a[j+1]=temp;
}
}
}
we use this command for(i=0;i<10;i++) and not this for(i=0;i<=10;i++)???
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|