Advertisement
anon20016

7

Jan 12th, 2020
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include "libarea.h"
  5.  
  6. int main()
  7. {
  8. int n;
  9. scanf("%d", &n);
  10. int a[1000];
  11. for (int i =0; i < n; i++){
  12. scanf("%d", &a[i]);
  13. }
  14.  
  15. for (int i = 0; i < n; i++){
  16. for (int j = 0; j < n - 1; j++){
  17. if (a[j] > a[j + 1]){
  18. int t = a[j];
  19. a[j] = a[j + 1];
  20. a[j + 1] = t;
  21. }
  22. }
  23. }
  24.  
  25. for (int i =0; i < n; i++){
  26. printf("%d ", a[i]);
  27. }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement