mirror of
https://github.com/TheAlgorithms/Java.git
synced 2025-07-06 17:29:31 +08:00
Merge pull request #19 from Shubhk15/patch-1
Changes in for loop for sorting
This commit is contained in:
@ -15,15 +15,15 @@ class BubbleSort
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Sorting
|
//Sorting
|
||||||
for(int i=0; i<6; i++)
|
for(int i=0; i<5; i++)
|
||||||
{
|
{
|
||||||
for(int j=0; j<5; j++)
|
for(int j=i+1; j<6; j++)
|
||||||
{
|
{
|
||||||
if(array[j]>array[j+1])
|
if(array[j]>array[i])
|
||||||
{
|
{
|
||||||
int temp=array[j];
|
int temp=array[j];
|
||||||
array[j]=array[j+1];
|
array[j]=array[i];
|
||||||
array[j+1]=temp;
|
array[i]=temp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user