domingo, 22 de febrero de 2015

Prueba Logica Visual C++


#include <cstdio>
#include <cstdlib>
#include <iostream>

using namespace std;

int main( int argc , char *argv[] )
{
 //Establezco mi salida para formato hexadecimal
 cout.unsetf( cout.dec );
 cout.setf( cout.hex );

 //inicializo dos argumentos
 int arg1 = 0x78ABCDEF;
 int arg2 = 0x12345678;

 //Ahora realizo cada operacion en turno
 //primero el operador unario NOT
 cout << "arg1 = 0x " << arg1 << endl;
 cout << "~arg1 = 0x " << ~arg1 << "\n" << endl;
 cout << "arg2 = 0x " << arg2 << endl;
 cout << "~arg2 = 0x " << ~arg2 << "\n" << endl;

 //Ahora los operadores binarios
 cout << "  0x" << arg1 << "\n"
   << "& 0x" << arg2 << "\n"
   << "----------- " << "\n"
   << "  0x" << ( arg1 & arg2 ) << "\n"
   << endl;

 cout << "  0x" << arg1 << "\n"
   << "| 0x" << arg2 << "\n"
   << "  0x" << ( arg1 | arg2 ) << "\n"
   << endl;

 cout << "  0x" << arg1 << "\n"
   << "^ 0x" << arg2 << "\n"
   << "----------- " << "\n"
   << "  0x" << ( arg1 ^ arg2 ) << "\n"
   << endl;

 system("pause");

 return 0;
}

No hay comentarios:

Publicar un comentario