#include
#include
#include
double _rand(void)
{
FILE *file;
double x, value;
file = fopen ("rand.txt", "r");
fscanf(file,"%lf",&x);
value = x*x + x - 1;
if (value < 0)
{
value = -value;
}
file = fopen ("rand.txt", "w");
fprintf (file, "%lf", value);
fclose(file);
return value;
}
int main()
{
again:
printf ("產生了一個亂數為 %.4lf\n", _rand());
system ("pause");
goto again;
return 0;
}
沒有留言:
張貼留言