30.10.2014 Views

F. Biblioteca de funciones estándar ANSI/ISO C++

F. Biblioteca de funciones estándar ANSI/ISO C++

F. Biblioteca de funciones estándar ANSI/ISO C++

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

658 PROGRAMACIÓN EN <strong>C++</strong>. ALGORITMOS, ESTRUCTURAS Y OBJETOS<br />

random<br />

#inclu<strong>de</strong> <br />

Rota el valor <strong>de</strong> x,c bits a la izquierda.<br />

int random(int x);<br />

Genera un número pseudoaleatorio en el rango <strong>de</strong> 0 a x-1.<br />

// obtener un número aleatorio entre 0 y 20<br />

numa1 = random(21);<br />

Funciones relacionadas: rand, randomize.<br />

mo<strong>de</strong>lo_nuevo = _rotl(0x1234,8);<br />

// resultado es 3412h<br />

Funciones relacionadas: _lrotl, _rotr, _rotr.<br />

_rotr<br />

unsigned _rotr(unsigned x, int c);<br />

#inclu<strong>de</strong> <br />

randomize<br />

#inclu<strong>de</strong> <br />

#inclu<strong>de</strong> <br />

Se utiliza _rotr para rotar a la <strong>de</strong>recha el valor <strong>de</strong> x,c bits.<br />

_rotr(val, 4);<br />

void randomize(void);<br />

Inicializa (genera una semilla) el generador <strong>de</strong> números pseudoaleatorios<br />

con una semilla aleatoria que es función <strong>de</strong> la hora actual. Esta función<br />

impi<strong>de</strong> que se repitan las mismas secuencias <strong>de</strong> números aleatorios en diferentes<br />

ejecuciones.<br />

randomize();<br />

Funciones relacionadas: rand, random, srand.<br />

real<br />

double real(complex x);<br />

double real(bcd x);<br />

#inclu<strong>de</strong> <br />

#inclu<strong>de</strong> <br />

Devuelve la parte real <strong>de</strong> un número complejo x o convierte un número<br />

BCD a float, double o long double.<br />

complex z = complex(x, y)<br />

cout

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!