faizaldianpr

megurutkan bilangan

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