Skip to content

Instantly share code, notes, and snippets.

@chorim
Last active June 5, 2019 11:29
Show Gist options
  • Save chorim/b94837b91833259fbd189c82552ee49b to your computer and use it in GitHub Desktop.
Save chorim/b94837b91833259fbd189c82552ee49b to your computer and use it in GitHub Desktop.
학교과제c
//
// main.c
// cstudy
//
// Created by Yukihira Nanako on 2019. 6. 5..
// Copyright © 2019년 유키유키. All rights reserved.
//
#include <stdio.h>
#define COUNT 4
void bubbleSort(int *dest) {
int temp = 0;
for (int i = 0; i < COUNT - 1; i++) {
for (int j = 0; j < COUNT - 1; j++) {
if ( dest[j] > dest[j + 1] ) {
temp = dest[j];
dest[j] = dest[j + 1];
dest[j + 1] = temp;
}
}
}
}
int main(int argc, const char * argv[]) {
// insert code here...
int a, b, c, d = 0;
scanf("%d %d %d %d", &a, &b, &c, &d);
int arr[COUNT] = {a,b,c,d};
bubbleSort(&arr);
printf("가장 작은 수 : ");
for(int i = 0; i < COUNT; i++) {
printf("%d", arr[i]);
}
printf("\n가장 큰 수 : ");
// reverse
for(int i = COUNT - 1; i >= 0; i--) {
printf("%d", arr[i]);
}
return 0;
}
// 내 과제아님;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment