Advertisement
Alx09

https://www.pbinfo.ro/probleme/3902/sortsum

Apr 9th, 2022
1,441
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.67 KB | None | 0 0
  1. #include<stdio.h>
  2.  
  3.  
  4. int sumCif(int n){
  5.  int sumCif = 0;
  6.     while(n != 0){
  7.        sum += (double)a / 10;
  8.         n /= 10;
  9.     }
  10.     return sumCif;
  11. }  
  12.  
  13.  
  14. void swap(int *xp, int *yp)
  15. {
  16.     int temp = *xp;
  17.     *xp = *yp;
  18.     *yp = temp;
  19. }
  20.  
  21. // A function to implement bubble sort
  22. void bubbleSort(int arr[], int n)
  23. {
  24.     int i, j;
  25.     for (i = 0; i < n-1; i++)    
  26.      
  27.     // Last i elements are already in place
  28.     for (j = 0; j < n-i-1; j++)
  29.         if (sumCif(arr[j]) > sumCif(arr[j+1]))
  30.             swap(&arr[j], &arr[j+1]);
  31.        else if (sumCif(arr[j]) == sumCif(arr[j+1]))
  32.             swap(&arr[j+1], &arr[j]);
  33. }
  34. int main(){
  35.    
  36. }
  37.    
  38.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement