Advertisement
Abelsor

Verificar Bianario

Feb 18th, 2022
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.54 KB | None | 0 0
  1. /*
  2.                 Verificar si un numero de 3 cifras es Binario
  3. */
  4. #include<iostream>
  5. using namespace std;
  6.  
  7. int main(){
  8.     int n;
  9.     cin>>n;
  10.     //DESARROLLE AQUI EL EJERCICIO
  11.     int a, b, c;
  12.    
  13.     if((n/100)<1 or (n/100 )>9)
  14.         cout<<"El numero ingresado no tiene 3 cifras"<<endl;
  15.    
  16.     else{
  17.         a = n/100;
  18.         b = (n/10)%10;
  19.         c = n%10;
  20.    
  21.         if((a==0 or a==1) and (b==0 or b==1) and (c==0 or c==1))
  22.         cout<<"Es un numero binario"<<endl;
  23.         else
  24.         cout<<"No es un numero binario"<<endl;
  25.     }
  26.    
  27.     return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement