Facebook
From Subtle Elephant, 3 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 55
  1. /******************************************************************************
  2.  
  3.                             Online C Compiler.
  4.                 Code, Compile, Run and Debug C program online.
  5. Write your code in this editor and press "Run" button to compile and execute it.
  6.  
  7. *******************************************************************************/
  8.  
  9. #include <stdio.h>
  10.  
  11. int main()
  12. {
  13.     int mesec = 5, dan= 10, max = 7, min = 1;
  14.     int niz[4]= {mesec,dan,max,min};
  15.    
  16.    
  17.     unsigned short br=0;
  18.     int pomb = 0;
  19.     int umnozak = 1;
  20.    
  21.     for(int i = 0;i<4;i++)
  22.     while(niz[i] !=0)
  23.     {
  24.         pomb++;
  25.         br=br+(niz[i]%2)*umnozak;
  26.         niz[i] = niz[i] /2;
  27.         umnozak*=2;
  28.     }
  29.    
  30.     br = br<<(16-pomb);
  31.     printf("%d",br);
  32.    
  33.     return 0;
  34. }
  35.