-
-
Save nickcharlton/1438545 to your computer and use it in GitHub Desktop.
butts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <math.h> | |
#include "mt64.h" | |
int n,i; //Define n and i as integers | |
double *array; //Dynamic array as a double | |
FILE *myfile; | |
int main() | |
{ | |
printf("How many numbers would you like? \n"); | |
scanf("%d",&n); //Scans for an integer the user enters | |
array = (double*)malloc(n*sizeof(double)); //Something something dynamic array? | |
init_genrand64(time(NULL)); //Sets the seed for the random number generator | |
for (i=0;i<n;i++) //Loops from i=0 to i=n, increments of 1 | |
{ | |
array[i]=genrand64_real3(); //Assigns a random number to element n of the array | |
printf("Array element %d is %f \n",i,array[i]); //Prints the array element value | |
} | |
i=0; //Reset i to 0 | |
myfile=fopen("prototype.txt","w"); //Open prototype.txt | |
for (i=0;i<n;i++) | |
{ | |
fprintf(myfile,"%f\n",array[i]); //Print a number from the array on | |
} | |
fclose(myfile); | |
free(array); //Frees the array? | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment