wojiaocbj

bubble

Apr 4th, 2022
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.52 KB | None | 0 0
  1. /*
  2.  Author: Cao Beijian
  3.  Result: AC Submission_id: 4276984
  4.  Created at: Tue Apr 05 2022 12:42:13 GMT+0800 (China Standard Time)
  5.  Problem: 5493  Time: 25    Memory: 1744
  6. */
  7.  
  8. #include <stdio.h>
  9. int main(){
  10.     double a[1024] = { 0 }, tmp;
  11.     int n, i, j;
  12.     scanf("%d", &n);
  13.     for(i = 0; i < n; i++){
  14.         scanf("%lf", a + i);
  15.     }
  16.     for(i = 0; i < n; i++){
  17.         for(j = i + 1; j < n; j++){
  18.             if(a[i] > a[j]){
  19.                 tmp = a[i]; a[i] = a[j]; a[j] = tmp;
  20.             }
  21.         }
  22.     }
  23.     for(i = 0; i < n; i++){
  24.         printf("%.5f\n", a[i]);
  25.     }
  26.     return 0;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment