Skip to content

Instantly share code, notes, and snippets.

@dukaev
Last active August 29, 2015 14:26
Show Gist options
  • Save dukaev/4020a32e05dd7dff4b30 to your computer and use it in GitHub Desktop.
Save dukaev/4020a32e05dd7dff4b30 to your computer and use it in GitHub Desktop.
Сортировка пузырьком
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char const *argv[])
{
int m[argc-1], i, temp, p, cc, s;
/* Заполняем массив из входными данными */
for (i = 0; i < argc-1; i++) m[i]=atoi(*(++argv));
/* Сортируем массив */
for (p = 0; p < argc-1; p++)
for (s = p; s < argc-1; s++)
if(m[p]>m[s]){
temp = m[s];
m[s] = m[p];
m[p] = temp;
}
/* Выводим результат */
for(cc = 0; cc < argc-1; cc++) printf("%d ", m[cc]);
printf("\n");
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment