Advertisement
Guest User

Untitled

a guest
Dec 9th, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. #include <vcl.h>
  2. #pragma hdrstop
  3.  
  4. #include <tchar.h>
  5. #include <conio.h>
  6. #include <iostream.h>
  7. #include <windows.h>
  8. #include <string.h>
  9. #include <stdio.h>
  10.  
  11.  
  12. #pragma argsused
  13.  
  14. int _tmain(int argc, _TCHAR* argv[]) {
  15. SetConsoleCP(1251);
  16. SetConsoleOutputCP(1251);
  17. char d[9] = {'\0'};
  18. int est = 0;
  19. cout << "Введите дополнительный код:" << endl;
  20. gets(d);
  21. cout << "Естественная форма:" << endl;
  22. if (d[0] == '0')
  23. cout << '+';
  24. else if (d[0] == '1') {
  25. cout << '-';
  26. for (int i = 7; i > 0; i--) {
  27. if (d[i] == '1') {
  28. d[i] = '0';
  29. for (int j = i + 1; j < 8; j++) {
  30. d[j] = '1';
  31. }
  32. for (int j = 1; j < 8; j++) {
  33. if (d[j] == '1')
  34. d[j] = '0';
  35. else
  36. d[j] = '1';
  37. }
  38. break;
  39. }
  40. }
  41.  
  42. }
  43.  
  44. for (int i = 1; i < 8; i++) {
  45. est = est * 2+int(d[i]) - 48;
  46. }
  47.  
  48. cout << est;
  49.  
  50. getch();
  51. return 0;
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement