Alx09

Untitled

May 7th, 2020
1,110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.30 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<stdlib.h>
  3.  
  4.  
  5.  
  6. int main(void) {
  7.     unsigned n, i = 0, z = 0;
  8.     FILE *f;
  9.     f = fopen("in.txt", "r");
  10.     fscanf(f, "%u", &n);
  11.     fclose(f);
  12.     while (n >> i) {
  13.         z += ~n & (1 << i);
  14.         i++;
  15.     }
  16.     f = fopen("out.txt", "w");
  17.     fprintf(f, "%u", z);
  18.     system("pause");
  19.     return 0;
  20. }
Advertisement
Add Comment
Please, Sign In to add comment