📄 misc.c
字号:
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include "misc.h"
void *My_Malloc(long size)
{
void *ptr;
ptr=(void *)malloc(size);
if(!ptr)
{
My_Error("Out of memory!");
}
return(ptr);
}
void My_Error(char error_text[])
{
printf("\n\nFatal Error ...\n\n");
printf("%s\n",error_text);
printf("...now exiting...\n\n");
exit(-1);
}
/* skiptoend - routine to read comments in data file up to end of line */
void skiptoend(FILE *fp)
{
register int c;
while ((c = getc(fp)) != EOF && c != '\n');
}
float ran4(long *idum);
long my_idum;
long my_idum_action_selection,Memorize_my_idum_action_selection;
void Reset_Random_Seed_For_Paths(void)
{
Memorize_my_idum_action_selection = (long)(10000000 * ran4(&my_idum));
}
double My_Rand_Action_Selection(void)
{
return(ran4(&my_idum_action_selection));
}
void My_Seed_Rand_Action_Selection(void)
{
//my_idum = (unsigned)time( NULL );
my_idum_action_selection = Memorize_my_idum_action_selection;
}
double My_Rand(void)
{
return(ran4(&my_idum));
}
void My_Seed_Rand(void)
{
my_idum = (unsigned)time( NULL );
my_idum_action_selection = (unsigned)time( NULL );
//my_idum = 12345;
//my_idum_action_selection = 123456;
Memorize_my_idum_action_selection = my_idum_action_selection;
}
void My_Seed_Rand_Fixed(void)
{
my_idum = 345;
my_idum_action_selection = 3456;
Memorize_my_idum_action_selection = my_idum_action_selection;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -