remove std and fixed style on clang-format

This commit is contained in:
beqakd 2020-06-05 18:43:31 +04:00
parent 8f4f8cdd7a
commit 12a8996049

View File

@ -1,29 +1,30 @@
#include <iostream> #include <iostream>
using namespace std;
void gnomesort(int arr[], int size) { void gnomesort(int arr[], int size) {
// few easy cases // few easy cases
if (size <= 1) return; if (size <= 1)
return;
int index = 0; // initialize some variables. int index = 0; // initialize some variables.
while (index < size) { while (index < size) {
// check for swap // check for swap
if ((index == 0) || (arr[index] >= arr[index - 1])) { if ((index == 0) || (arr[index] >= arr[index - 1])) {
index++; index++;
} else { } else {
swap(arr[index], arr[index - 1]); // swap std::swap(arr[index], arr[index - 1]); // swap
index--; index--;
}
} }
}
} }
// Our main function // Our main function
int main() { int main() {
int arr[] = {-2, -10, 100, 35, 34, 99}; int arr[] = {-2, -10, 100, 35, 34, 99};
int size = sizeof(arr) / sizeof(arr[0]); int size = sizeof(arr) / sizeof(arr[0]);
gnomesort(arr, size); gnomesort(arr, size);
for (int i = 0; i < size; i++) printf("%d ", arr[i]); for (int i = 0; i < size; i++)
printf("%d ", arr[i]);
return 0; return 0;
} }