SHARE
TWEET

Untitled

a guest Jun 16th, 2019 57 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //
  2. //  main.c
  3. //  cstudy
  4. //
  5. //  Created by Yukihira Nanako on 2019. 6. 5..
  6. //  Copyright © 2019년 유키유키. All rights reserved.
  7. //
  8.  
  9. #include <stdio.h>
  10.  
  11. #define COUNT 4
  12.  
  13. void bubbleSort(int *dest) {
  14.     int temp = 0;
  15.  
  16.     for (int i = 0; i < COUNT - 1; i++) {
  17.         for (int j = 0; j < COUNT - 1; j++) {
  18.             if ( dest[j] > dest[j + 1] ) {
  19.                 temp = dest[j];
  20.                 dest[j] = dest[j + 1];
  21.                 dest[j + 1] = temp;
  22.             }
  23.         }
  24.     }
  25.  
  26. }
  27.  
  28.  
  29. int main(int argc, const char * argv[]) {
  30.     // insert code here...
  31.     int a, b, c, d = 0;
  32.    
  33.     scanf("%d %d %d %d", &a, &b, &c, &d);
  34.    
  35.     int arr[COUNT] = {a,b,c,d};
  36.  
  37.     bubbleSort(&arr);
  38.     printf("가장 작은 수 : ");
  39.     for(int i = 0; i < COUNT; i++) {
  40.         printf("%d", arr[i]);
  41.     }
  42.    
  43.    
  44.     printf("\n가장 큰 수 : ");
  45.    
  46.     // reverse
  47.     for(int i = COUNT - 1; i >= 0; i--) {
  48.         printf("%d", arr[i]);
  49.     }
  50.    
  51.    
  52.     return 0;
  53. }
  54. // 내 과제아님;
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top