Advertisement
Guest User

Untitled

a guest
Nov 24th, 2014
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.22 KB | None | 0 0
  1. 6)int main()
  2. {
  3.   int z,i,a,b,nod;
  4.   cin>>a>>b;
  5.   nod=0;
  6.   z=0;
  7.   if ((a%2==0)||(b%2==0))
  8.     {
  9.         if(a%2==0){a=a<<1;z+=1;}
  10.         if(b%2==0){b=b<<1;z+=1;}
  11.     }
  12.  
  13.   if (a>b)
  14.   {
  15.       for(i=b;i>0;--i)
  16.       {
  17.           if ((a%i==0)&&(b%i==0))
  18.           {
  19.               nod=i;
  20.               if (z==2){nod=nod>>1;}
  21.               break;
  22.           }
  23.       }
  24.   }
  25.   else
  26.   {
  27.     for(i=a;i>0;--i)
  28.       {
  29.           if ((a%i==0)&&(b%i==0))
  30.           {
  31.               nod=i;
  32.               if (z==2){nod=nod>>1;}
  33.               break;
  34.           }
  35.       }
  36.   }
  37.   cout<<nod;
  38. }
  39.  
  40. ------------------------------------------------------------------------
  41. 10.
  42. int main()
  43. {
  44.   int i,n,s;
  45.   cin>>n;
  46.   i=0;
  47.   s=1;
  48.   while (s<=n)
  49.   {
  50.       if(s==n){i=1;}
  51.       s=s<<1;
  52.   }
  53.   if (i==1){cout<<"YES";}
  54.   else {cout<<"NO";}
  55. }
  56. ------------------------------------------------------------------------
  57. 11.
  58. int main()
  59. {
  60.   int i,n;
  61.   cin>>n;
  62.   i=1;
  63.   while (i<=n)
  64.   {
  65.       cout<<i<<" ";
  66.       i=i<<1;
  67.   }
  68. }
  69. ------------------------------------------------------------------------
  70. 12.
  71. int main()
  72. {
  73.   int i,n,s;
  74.   cin>>n;
  75.   i=1;
  76.   s=0;
  77.   while (i<n)
  78.   {
  79.       ++s;
  80.       i=i<<1;
  81.   }
  82.   cout<<s;
  83. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement