Advertisement
STANAANDREY

CifR

Mar 12th, 2019
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.45 KB | None | 0 0
  1. #include<iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6. long x;
  7. cin>>x;
  8. int cif[10],poz[10],i,j,aux1,aux2;
  9.  
  10. for (int i=0;i<10;i++)
  11. {
  12.     poz[i]=i;
  13.     cif[i]=0;
  14. }
  15.  
  16. while (x)
  17. {
  18.  cif[x%10]++;
  19.     x/=10;
  20. }
  21.  
  22. for (i=0;i<9;i++)
  23. for (j=i+1;j<=9;j++)
  24.     if (cif[i]>cif[j])
  25. {
  26.     aux1=cif[i];
  27.     cif[i]=cif[j];
  28.     cif[j]=aux1;
  29.     aux2=poz[i];
  30.     poz[i]=poz[j];
  31.     poz[j]=aux2;
  32. }
  33. for (i=0;i<=9;i++)
  34.     cout<<poz[i]<<' ';
  35. return 0;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement