All pastes #1065585 Raw Edit

Someone

public text v1 · immutable
#1065585 ·published 2008-07-08 15:07 UTC
rendered paste body
typedef struct _Phase
{
	struct _Phase *next_phase;
	char *name;
	double a, b, c, d, h, s, t_max, t_min;
} Phase;

Phase *findPhaseByTemp(Phase*, double);
Phase *findPhaseByName(Phase*, char*);
void phaseSummary(Phase*);

Phase *findPhaseByTemp (Phase *p, double t)
{
	while(p != NULL)
	{
		if(t >/*=*/ p -> t_min && t <= p -> t_max)//took out the equals for better "finding" because t_max  (first element) == t_min (next elemnt)
			return p;
		p = p -> next_phase;
	}
	return NULL;
}

Phase *findPhaseByName(Phase *p, char *name)
{
	while (p != NULL)
	{
		if (strCompare (p -> name, name) == 1)
			return p;
		p = p -> next_phase;
	}
	return NULL;
}

void phaseSummary (Phase *p)
{
	puts("------------------------------------");
	printf("phase name:\t%s\n", p -> name);
	printf("phase a:\t%e\n", p -> a);
	printf("phase b:\t%e\n", p -> b);
	printf("phase c:\t%e\n", p -> c);
	printf("phase d:\t%e\n", p -> d);
	printf("phase t_min:\t%e\n", p -> t_min);
	printf("phase t_max:\t%e\n", p -> t_max);
	printf("phase S:\t%e\n", p -> s);
	printf("phase H:\t%e\n", p -> h);
	puts("------------------------------------");
}