Advertisement
rotti321

Untitled

Mar 31st, 2017
201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.89 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4. int a[101]={},poz[101]={};
  5. ifstream f("subnumar.in");
  6. ofstream g("subnumar.out");
  7.  
  8. void prelucrare(int x)
  9. {
  10.     int nr;
  11.     while(x>9)
  12.     {
  13.         //nr=((x/10)%10)*10+x%10;
  14.         nr=x%100;
  15.         a[nr]++;
  16.         x=x/10;
  17.     }
  18. }
  19. int main()
  20. {
  21.     int x;
  22.     while(f>>x)
  23.     {
  24.         prelucrare(x);
  25.     }
  26.     for(int i=10;i<=99;i++)
  27.     {
  28.         poz[i]=i;
  29.     }
  30.      int ok=1;
  31.     do
  32.     {
  33.         ok=1;
  34.         for(int i=11;i<=99;i++)
  35.         {
  36.             if(a[i-1]>a[i])
  37.             {
  38.                 swap(a[i-1],a[i]);
  39.                 swap(poz[i-1],poz[i]);
  40.                 ok=0;
  41.             }
  42.         }
  43.     }
  44.     while(ok==0);
  45.     for(int i=99;i>=10;i--)
  46.     {
  47.         //cout<<poz[i]<<" ";
  48.         if(a[i]==a[99])
  49.         g<<poz[i]<<" ";
  50.       //  else
  51.       //      break;
  52.     }
  53.  
  54.     return 0;
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement