#include<stdio.h>
#include<limits.h>
#include<stdlib.h>

double add(double a, double b){ return a + b; }
double mal(double a, double b){ return a * b; }
double minus(double a, double b){ return a - b; }
double divid(double a, double b){ return a / b; }

typedef double (*funcp)(double, double);
typedef struct node_t{
	char op;
	funcp fn;
	struct node_t *next;
} Node;


Node* new_node(char c, funcp fn)
{
	Node* ret = (Node *)malloc(sizeof(Node));
	ret->op = c;
	ret->fn = fn;
	ret->next = NULL;
	return ret;
}

Node* add_node(Node *head, char c, funcp fn)
{
	Node *next= new_node(c,fn);
	Node *idx = head;
	while(idx->next) idx = idx->next;
	idx->next = next;
	return head;
}

Node* search(Node *node, const char c)
{
	if (!node){ return NULL;}
	else if(c == node->op){ return node;}
	else { return search( node->next, c );}
}

int main()
{
char d = '*';
double val;
Node *head = new_node(' ',NULL);
add_node(head, '+', add);
add_node(head, '*', mal);
add_node(head, '-', minus);
add_node(head, '/', divid);
val = search(head, d)->fn(6,9);
printf("%lf\n", val);
return 0;
}