/*****************************************
* This example shows "search" for linked lists.
*****************************************/
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
struct Node
{
double data;
Node *next;
};
Node* add2front(double val, Node* L);
void printlist(Node* L);
Node* search(double x, Node* L);
/*****************************************
** MAIN
*****************************************/
int main()
{
// Get original list of values from user
// comma-separated, semi-colon terminated.
Node* L = NULL;
double x;
char c = ',';
while(c == ',' && cin >> x >> c)
{
L = add2front(x,L);
}
string comm;
while(cin >> comm && comm == "search" && cin >> x)
{
Node* p = search(x,L);
if (p != NULL)
cout << "Found!" << endl;
else
cout << "Not Found!" << endl;
}
return 0;
}
/*****************************************
** Function definitions
*****************************************/
Node* add2front(double val, Node* L)
{
Node* T = new Node{val, L};
return T;
}
void printlist(Node* L)
{
for(Node* T = L; T != NULL; T = T->next)
cout << T->data << ' ';
}
bool match(double a, double b)
{
return fabs(a - b) < 0.0001;
}
Node* search(double x, Node* L)
{
}