-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsearch.cpp
More file actions
29 lines (26 loc) · 804 Bytes
/
Copy pathsearch.cpp
File metadata and controls
29 lines (26 loc) · 804 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
/* TODO: write a function that takes an integer x and a list, and searches for
* x in the list, returning a boolean indicating whether or not x was found. */
#include <iostream>
using std::cout;
using std::cin;
/* NOTE: the node structure, as well as some utility functions used in
* main() are in list-utils.h which we include here. */
#include "list-utils.h"
bool search(node* L, int x)
{
/* TODO: write me */
return false; /* just so it compiles... */
}
int main()
{
/* NOTE: some test code for you is given below. It makes a fixed
* list of integers and then runs searches against that from values
* given on stdin. */
node* L = buildlist({1,3,5,7,9,11,13});
printlist(L);
int x;
while (cin >> x)
printf("%i was %sfound\n",x,search(L,x)?"":"not ");
return 0;
}
// vim:foldlevel=2