Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Verificar si un numero de 3 cifras es Binario
- */
- #include<iostream>
- using namespace std;
- int main(){
- int n;
- cin>>n;
- //DESARROLLE AQUI EL EJERCICIO
- int a, b, c;
- if((n/100)<1 or (n/100 )>9)
- cout<<"El numero ingresado no tiene 3 cifras"<<endl;
- else{
- a = n/100;
- b = (n/10)%10;
- c = n%10;
- if((a==0 or a==1) and (b==0 or b==1) and (c==0 or c==1))
- cout<<"Es un numero binario"<<endl;
- else
- cout<<"No es un numero binario"<<endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement