Ejemplo n.º 1
0
void main()
{
	struct node* a = buildlistattail(10);
	struct node* b = buildlistathead(10);

	print(a);
	printf("\nlen(a) = %d\n", len(a));
	print(b);
	printf("\nlen(b) = %d\n", len(b));
	printf("\ngetnthfromend = %d\n", getnthfromend(a, 9));
	getmiddle(a);
}
Ejemplo n.º 2
0
void main(){
	float x1=1,x2=10,x;
	float y1,y2,y,max;
	float getmiddle(float,float);//function to get the middle value of x1 and x2.
	float getval(float);//function to get the y corresponding to x.
	//scanf("%f %f",&x1,&x2);
	do{
		x  = getmiddle(x1,x2);
		y  = getval(x);
		y1 = getval(x1);
		y2 = getval(x2);
		if((y*y1>0)) x1 = x;
		if((y*y2>0)) x2 = x;
	}while(fabs(y)>0.0001);
	printf("A root of equation is %8.4f",x);
}