Advertisement
Guest User

Untitled

a guest
Apr 25th, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. #define _CRT_SECURE_NO_WARNINGS
  2. #include <stdio.h>
  3. #include <math.h>
  4. int main()
  5. {
  6. FILE* f1;
  7. FILE* f2;
  8. f1 = fopen("2.bmp", "rb");
  9. f2 = fopen("out.txt", "wb");
  10. unsigned char c1, c2=0;
  11. int t, i1=0, i2, l = 0, k;
  12. char I=0;
  13. if (f1 == NULL)
  14. return 0;
  15. scanf("%i", &k);
  16. for (int i = 0; i < 144; i++)
  17. {
  18. c1 = fgetc(f1);
  19. }
  20. while (!feof(f1))
  21. {
  22. c1 = fgetc(f1);
  23. i1 = 0;
  24. for (int i = 0; i < 8; i++)
  25. {
  26. i1 = i1 + (c1 % 2)*pow(10, i);
  27. c1 /= 2;
  28. }
  29. for (int j=0; j<k; j++)
  30. {
  31. I = I + (i1 % 10)*pow(2, l);
  32. i1 /= 10;
  33. l++;
  34. if (l == 8)
  35. {
  36. l = 0;
  37. fputc(I, f2);
  38. I = 0;
  39. }
  40. }
  41. }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement