Advertisement
Patey

Untitled

Apr 15th, 2021
720
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.53 KB | None | 0 0
  1. #include<stdlib.h>
  2. #include<stdio.h>
  3.  
  4.  
  5. int main()
  6. {
  7.     int A, B, C,A_putere,B_putere,i,j,ok,p;
  8.  
  9.     printf("A=");
  10.     scanf("%d", &A);
  11.     printf("B=");
  12.     scanf("%d", &B);
  13.     printf("C=");
  14.     scanf("%d", &C);
  15.  
  16.     A_putere = 1 << A;
  17.     B_putere = 1 << B;
  18.  
  19.  
  20.     for (i = A_putere; i <= B_putere; i++)
  21.     {
  22.         p = 1;
  23.         j = C;
  24.         ok = 1;
  25.         while (j <= B)
  26.         {
  27.             if ((i >> j) & 1)
  28.             {
  29.                 p++;
  30.                 j = p * C;
  31.             }
  32.             else
  33.             {
  34.                 ok = 0;
  35.                 break;
  36.             }
  37.         }
  38.         if (ok == 1)
  39.             printf("%d\n", i);
  40.     }
  41.  
  42.     system("pause");
  43.     return 0;
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement