Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <vcl.h>
- #pragma hdrstop
- #include <tchar.h>
- #include <conio.h>
- #include <iostream.h>
- #include <windows.h>
- #include <string.h>
- #include <stdio.h>
- #pragma argsused
- int _tmain(int argc, _TCHAR* argv[]) {
- SetConsoleCP(1251);
- SetConsoleOutputCP(1251);
- char d[9] = {'\0'};
- int est = 0;
- cout << "Введите дополнительный код:" << endl;
- gets(d);
- cout << "Естественная форма:" << endl;
- if (d[0] == '0')
- cout << '+';
- else if (d[0] == '1') {
- cout << '-';
- for (int i = 7; i > 0; i--) {
- if (d[i] == '1') {
- d[i] = '0';
- for (int j = i + 1; j < 8; j++) {
- d[j] = '1';
- }
- for (int j = 1; j < 8; j++) {
- if (d[j] == '1')
- d[j] = '0';
- else
- d[j] = '1';
- }
- break;
- }
- }
- }
- for (int i = 1; i < 8; i++) {
- est = est * 2+int(d[i]) - 48;
- }
- cout << est;
- getch();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement