Skip to content

Commit c2b8f4d

Browse files
committed
changes in programs
1 parent e2d6e6f commit c2b8f4d

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

milestone2/arrays/SwapAlternate.cpp

+3-7
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,10 @@
1414
void swapAlternate(int *arr, int size)
1515
{
1616
int temp;
17-
int i = 0, j = i+1;
18-
19-
while(j < size){
17+
for(int i=0; i<size-1; i+=2){
2018
temp = arr[i];
21-
arr[i] = arr[j];
22-
arr[j] = temp;
23-
i=i+2;
24-
j=i+1;
19+
arr[i] = arr[i+1];
20+
arr[i+1] = temp;
2521
}
2622
}
2723

0 commit comments

Comments
 (0)