Advertisement
StoneHaos

119

Oct 29th, 2019
316
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.46 KB | None | 0 0
  1. //119
  2. #include <cstdio>
  3.  
  4. char bits[16];
  5.  
  6. int main(void) {
  7.     FILE* fin = fopen("input.txt", "r");
  8.     FILE* fout = fopen("output.txt", "w");
  9.  
  10.     int n, cnt = 0;
  11.     fscanf(fin, "%d", &n);
  12.     fclose(fin);
  13.     if (n == 0) {
  14.         fprintf(fout, "0\n");
  15.         fclose(fout);
  16.         return 0;
  17.     }
  18.     for (; n != 0; ++ cnt, n >>= 1) {
  19.         if (n % 2 == 0)
  20.             bits[14 - cnt] = 0x30;
  21.         else
  22.             bits[14 - cnt] = 0x31;
  23.     }
  24.     fprintf(fout, "%s\n", bits + 15 - cnt);
  25.     fclose(fout);
  26.     return 0;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement