Advertisement
dllbridge

Untitled

Mar 24th, 2025
235
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.34 KB | None | 0 0
  1.  
  2.  
  3. #include <stdio.h>
  4.  
  5. int  main()
  6. {
  7.     int v = 0, b = 0, nRes = 0;
  8.         printf("Enter  number");
  9.     scanf("%d", &b);
  10.     printf("Enter  number");
  11.     scanf("%d", &v);
  12.    
  13.     nRes = (v >b) ? v : b;  // Придумать два примера с этим оператором
  14.    
  15.     printf("%d", nRes);
  16.  
  17. }
  18.  
  19.  
  20.  
  21.  
  22.  
  23.  
  24.  
  25.  
  26.  
  27.  
  28.  
  29.  
  30.  
  31.  
  32.  
  33.  
  34.  
  35. /*
  36. #include   <stdio.h>
  37. #include  <locale.h>  
  38.  
  39.  
  40. /////////////////////////////////////////////////
  41. void printBinary(int num)                      //  
  42. {
  43.    
  44.     int numBits = 32;
  45.  
  46.  
  47.     for (int i = numBits - 1; i >= 0; i--)     // Перебираем все биты, начиная со старшего
  48.     {
  49.    
  50.         if(num & (1 << i))  printf("1");       // Проверяем, установлен ли текущий бит
  51.         else                printf("0");
  52.        
  53.         if(i % 8 == 0)      printf(" ");       // Добавляем пробел для удобства чтения (например, каждые 8 бит)
  54.        
  55.     }
  56.     printf("\n");
  57. }
  58.  
  59.  
  60. ///////////////////////////////////////////////
  61. int main()                                   //
  62. {
  63.    
  64.     setlocale(LC_ALL, "rus");
  65.    
  66.    
  67.     int num = 42;
  68.    
  69.     printf("Десятичное число: %d\n", num);
  70.     printf("Двоичное представление: ");
  71.    
  72.     printBinary(num);
  73.  
  74. return 0;
  75. }
  76.  
  77. */
  78.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement