I am trying to find 6 number one is from 10-100 and the other five numbers are between 1-10 the articles that i read about generating new numbers was somehow complex for me to apply so i made a new simple way by By obtaining a series of repetitions of these numbers and put them in two dimensional array after that i used rand() as index to the first array parameter so i could find the random numbers but i have a problem ..i want to put the generated numbers in array because i want to use them later.
i'll be thanksfull if you explain in a simple way
enter code here
include<sys/time.h>
#include<stdio.h>
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
#include<time.h>
#include<ctime>
#define max 1000
int main(){
int o, gr1num1[max][1] ,n=6,q[max] ,i = 0, gr2num5[max][5];
while(1)
{ i++;
gr2num5[i][4]= rand() % 10+1 ;
if(i==1000)break;
}
if (gr2num5 [i][4]!=0)
srand(time(NULL));
printf("\ngroup 2 numbers %d ",gr2num5 [rand()%500][4]);
printf("\ngroup 2 numbers %d ",gr2num5 [rand()%500][4]);
printf("\ngroup 2 numbers %d ",gr2num5 [rand()%500][4]);
printf("\ngroup 2 numbers %d ",gr2num5 [rand()%500][4]);
printf("\ngroup 2 numbers %d ",gr2num5 [rand()%500][4]);
printf(" \n\n\n /// %d /// ",o);
while(1)
{ i++;
gr1num1[i][1]= rand() % 100+10;
if(i==1000)break;
}
printf("group 1 number %d",gr1num1 [rand()%500][1]);
}
Aucun commentaire:
Enregistrer un commentaire