Anonymous user
Sorting algorithms/Bubble sort: Difference between revisions
→{{header|C}}: swap function different from most. so I thought we shouldnt use it. And it now uses one char variable names.
(→{{header|Go}}: added more generic version) |
(→{{header|C}}: swap function different from most. so I thought we shouldnt use it. And it now uses one char variable names.) |
||
Line 225:
=={{header|C}}==
<lang c>
void
a[i] = a[i - 1];
a[i - 1] = t;
}▼
if (!s)
break;
}
int a[] = {4, 65, 2, -31, 0, 99, 2, 83, 782, 1};
int n = sizeof a / sizeof a[0];
▲ int i,sorted;
bubble_sort(a, n);
▲ do {
}
▲ for (i=0; i<size; i++)
▲ if (a[i+1] < a[i])
▲ {
▲ swap(a+i);
▲ sorted = 0;
▲ }
▲}</lang>
=={{header|C++}}==
|