I finally got code that's giving me random floats from 0 to 1. My code looks like this:
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
int main()
{
srand((int)time(NULL));
int N=10;
float a = 1.0;
for (int i=0;i<N;i++)
printf("%f\n", ((float)rand()/(float)(RAND_MAX)) * a);
return 0;
}
Now, I need to make program that will give me the average from given numbers for 10<=N<=10000, but im out of ideas how to make it works. Any ideas?
Aucun commentaire:
Enregistrer un commentaire