Last active
August 29, 2015 14:26
-
-
Save dukaev/4020a32e05dd7dff4b30 to your computer and use it in GitHub Desktop.
Сортировка пузырьком
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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