Welcome, guest! Login / Register - Why register?
Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)

Paste

Pasted as C++ by numeros aleatorios ( 14 years ago )
/* Codigo que llena un vector, una matriz y asigna una variable con numeros aleatorios en C 
//Solo les dejo las librerias y funciones necesarias 

#include<time.h> //libreria del random 
/************matriz**************/ 
void llenar_matriz_rand(int enc[][]){ 
srand(time(NULL)); //semilla 
for(i=1;i<MAX;i++){ 
for(j=1;j<=5;j++){ 
enc[j]=rand()%5; //rellena con numeros entre 0 y 4 
} 
} 
} 
/************vector**************/ 
void llenar_vector_rand(int v[]){ 
srand(time(NULL)); //semilla 
for(i=1;i<MAX;i++){ 
v=rand(); //rellena con numeros entre 0 y 9 
} 
} 
/***********numero random***********/ 
int numero_random(){ 
int n; 
srand(time(NULL)); //semilla 
n=rand() 0; //rellena con numeros entre 0 y 199 
return n; 
} 



************************************************* 
/*Suma de 2 numeros aleatorios (solo funcion) para C y C++*/ 

int suma(){ 
int a; 
a = rand()  + rand()0; 
return a; 
}

 

Revise this Paste

Your Name: Code Language: