Created
November 2, 2018 04:20
-
-
Save kjsman/d974a13d3d4c98936664403d75fc7f53 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> | |
#define INPUT_SIZE 6 | |
int loaded = 0; | |
int main(int dummy, int* dList) { | |
if(loaded) { | |
int i; | |
char chgFlag = 1; | |
int rangeNum = INPUT_SIZE - 1; | |
while (rangeNum > 0 && chgFlag) { | |
chgFlag = 0; | |
for (i = 0; i < rangeNum; i++) | |
if (dList[i] > dList[i + 1]) { | |
chgFlag = 1; | |
int temp = dList[i]; | |
dList[i] = dList[i + 1]; | |
dList[i + 1] = temp; | |
} | |
rangeNum--; | |
} | |
} | |
else { | |
loaded = 1; | |
int i; | |
int inputList[INPUT_SIZE]; | |
for (i = 0; i < INPUT_SIZE; i++) | |
scanf("%d", &inputList[i]); | |
main(INPUT_SIZE, inputList); | |
for (i = 0; i < INPUT_SIZE; i++) { | |
if (i) | |
printf(" "); | |
printf("%d", inputList[i]); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment