Advertisement
Guest User

ani

a guest
Feb 20th, 2019
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.34 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. //napishete funkciq sorts s masiv ot long long purvo da gi podredi namalqvashto po sumata ot ciftire
  4. //pri ednakva suma ot cifrite rastqshto po golemina
  5. //interfeisa void sortS(int n,long long a[])
  6. //vhod {556,918,6,13,402,51}
  7. //izhod {918,556,6,51,402,13}
  8. void input (int n,long long a[])
  9. {
  10.     for(int i=0;i<n;i++)
  11.         cin>>a[i];
  12.     }
  13. void output(int n,long long a[])
  14. {
  15.     for(int i=0;i<n;i++)
  16.         cout<<a[i]<<' ';
  17.     }
  18. int Sum(long long a)
  19. {
  20.     int s=0;
  21.     while (a)
  22.     {
  23.         s=s+a%10;
  24.         a=a/10;
  25.     }
  26.     return s;
  27. }
  28. void sortS(int n,long long a[])
  29. {
  30.     int i,j,temp;
  31.     for (i=0;i<n-1;i++)
  32.     {
  33.         for (j=1;j<n-i;j++)
  34.             if(Sum(a[j-1])<Sum(a[j]))
  35.         {
  36.             temp=a[j-1];
  37.             a[j-1]=a[j];
  38.             a[j]=temp;
  39.             continue;
  40.         }
  41.         if(Sum(a[j-1])==Sum(a[j]) && a[j-1]>a[j])
  42.         {
  43.             temp=a[j-1];
  44.             a[j-1]=a[j];
  45.             a[j]=temp;
  46.         }
  47.     }
  48. }
  49. int sortP(long long a)
  50. {int br=0;
  51.  
  52.     while(a)
  53.     {while(a%2==0) {br++;
  54.     a=a/2;}
  55.     if(a%2!=0) break;
  56.     a=a/2;
  57.     }
  58.         return br;
  59. }
  60.  
  61. int main()
  62. {int n;
  63. //cin>>n;
  64. //long long a[100];
  65. //input(n,a);
  66. //output(n,a);
  67. //cout<<endl;
  68. //sortS(n,a);
  69. //output(n,a);
  70. cout<<sortP(13);
  71. return 0;
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement