Advertisement
Guest User

Untitled

a guest
May 24th, 2019
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. #ifndef my_sort_razrad_hpp
  2. #define my_sort_razrad_hpp
  3. #include <stdio.h>
  4. #include <iostream>
  5. #include <cmath>
  6. using namespace std;
  7.  
  8. int my_sort_razrad (int a[],int max){
  9.  
  10. int b[max],i,maxi(0),kol(0),del,j,c,l,k,buf;
  11. for(i=0;i<max;i++){
  12. if(a[i]>maxi)
  13. maxi=a[i];
  14. }
  15. while(maxi!=0){
  16. kol++;
  17. maxi/=10;
  18. }
  19. for (i=1;i<(kol+1);i++){
  20. del=pow(10,i);
  21. l=0;
  22. for (c=0;c<10;c++){
  23. for(j=0;j<max;j++){
  24. if(abs(((a[j]/(del/10))%10))==c){
  25. b[l]=a[j];
  26. l++;
  27. }
  28. }
  29. }
  30. for(k=0;k<max;k++){
  31. a[k]=b[k];
  32. cout<<a[k]<<" ";
  33. }
  34. cout<<endl;
  35. }
  36. for(i=0;i<max;i++){
  37. if(a[i]<0){
  38. buf=a[i];
  39. for(j=i-1;j>=0;j--)
  40. a[j+1]=a[j];
  41. a[0]=buf;
  42. }
  43. }
  44. for(i=0;i<max;i++){
  45. cout<<a[i]<<" ";
  46. }
  47. cout<<endl;
  48.  
  49. return *a;
  50. }
  51. #endif /* my_sort_razrad_hpp */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement