fork download
  1. #define _CRT_SECURE_NO_WARNINGS
  2. #include <stdio.h>
  3.  
  4. #include <stdlib.h>
  5. #include <time.h>
  6. void test()
  7. {
  8. int i;
  9.  
  10. srand((unsigned)time(NULL));
  11. for (i = 0; i < 50; i++) {
  12. printf("%f\n", (double)rand() * rand() / RAND_MAX);
  13. }
  14. }
  15.  
  16. int main()
  17. {
  18. FILE* p;
  19. double d[50], t;
  20. int n, i, j;
  21.  
  22. scanf("%d", &n);
  23.  
  24. // p = fopen("double.txt", "rt");
  25. p = stdin;
  26. if (p == NULL) {
  27. return 1;
  28. }
  29. for (i = 0; i < n; i++) {
  30. fscanf(p, "%lf", &d[i]);
  31. }
  32. // fclose(p);
  33.  
  34. for (i = 0; i < n-1; i++) {
  35. for (j = 0; j < n-1-i; j++) {
  36. if (d[j] > d[j+1]) {
  37. t = d[j];
  38. d[j] = d[j+1];
  39. d[j+1] = t;
  40. }
  41. }
  42. }
  43.  
  44. // p = fopen("sort.txt", "wt");
  45. p = stdout;
  46. for (i = 0; i < n; i++) {
  47. fprintf(p, "%f\n", d[i]);
  48. }
  49. // fclose(p);
  50.  
  51. return 0;
  52. }
  53.  
Success #stdin #stdout 0.01s 1680KB
stdin
10
6417.510849
27524.366894
6676.717429
1831.403546
1933.945738
2419.973479
13696.957366
1515.407544
9705.411908
6319.215491
stdout
1515.407544
1831.403546
1933.945738
2419.973479
6319.215491
6417.510849
6676.717429
9705.411908
13696.957366
27524.366894