

m[w][p] is true iff word w appears on page p.

m[any][*] & m[nail][*]
m[*][3] & m[*][102]
add_page(page p) - add the words from p to the matrix.
while inf >> p m.add_page(p)
get_slice(query q) - return a slice that's the and of all the
query elements.
while cin >> q cout << m.get_slice(q)

query q while cin >> q cout << m.get_slice(q)
class query
enum q_type { words, pages }
q_type t
string * words
int * pages
PAGE 1 cat |
PAGE 1 cat blue emerald PAGE 2 cat red diamond PAGE 3 dog blue diamond |
| Tests | |||||||
| 1 | 2 | 3 | 4 | 5 | 6 | 7 | |
| 1 | |||||||
| 2 | |||||||
| 3 | |||||||
| 4 | |||||||
| 5 | |||||||
bool searchPage( string a[], List * word, int y, int page)
/* STORE THE FIRST QUERY PAGE'S UNIQUE WORDS */ int store_words(string* pt, int count, int in)
bool List::first(ListElementType & elem); // Precondition: true. // Postcondition: if this list is empty, elem is undefined, // otherwise elem is a reference to the first item. // Returns: true if and only if elem is defined.
#include <iostream> #include <fstream> #include <string>#include <vector>#include <list>#include <map>#include <stdlib.h>
int main(int argc char * argv[]) { ... }
argc?
argc (the argument count): an int whose value
is the number of strings on the command line argc is one past the last legal value in argv (me).
argv[argc] is never valid (off-by-1 error).
int main (int argc,char *argv[])
ifstream myfile(argv[1])
int main(int argc, char *argv[])
string infile(argv[1])
ifstream fin
fin.open(infile.c_str())
int main (int argc, char ** argv)
if (argc == 1) { cerr << emsg; exit(0) }
string filename = argv[1]
int main(int argc, char** argv)
if (argc != 2) cout << emsg
ifstream infile(argv[1])
int * arrayInt = new int[QueryPages.Size()] int cnt = 1 do cnt++ second = Text[arrayInt[cnt]] while cnt < QueryPages.Size()
$ ./concord smith.txt ? 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Segmentation fault (core dumped) $ ./concord smith.txt ? 2 3 4 5 6 7 8 9 10 11 12 13 14 and as be it not of that the ? 2 3 4 5 6 7 8 9 10 11 12 13 14 15 and as be it not of that the ?
int answer[1000] int pagefound = 0 answer[pagefound] = i pagefound++
char buf[256] memset(buf, '\0', 256) line.copy(buf, 256)
class List {
public:
List();
void insert(const ListElementType &)
bool first(ListElementType &)
bool next(ListElementType &)
private:
Node * link
}
|
|