#include using namespace std; int main() { int n, heso, tong = 0, nhan; cout << "Nhap so nhi phan: "; cin >> n; for (int i = 0; n != 0;i++) { heso = n % 10; if (heso != 0 && heso != 1) { cout << "Nhap sai so."; tong = 0; break; } if (heso != 0) { nhan = pow(2, i); tong += nhan; } n = n / 10; } if (tong != 0) { cout << "Thap phan la: " << tong; } }