virtual void event_pushWorld() { trace.push_back(TraceList(TraceEvent(TraceEvent_Branch))); }
TracerGenerator(MemoryBacktracker* mb) : BacktrackableType(mb), trace(mb->makeRevertingStack<TraceList>()) { trace.push_back(TraceList()); }
void beginConstraint(TraceEvent id) { trace.push_back(TraceList(id)); }
int main(void) { // Construct list pWord* hashList = (pWord*)malloc(260 * sizeof(pWord)); for (int i = 0; i < 260; ++i) { hashList[i] = NULL; } // Read and save words char allInput[40]; int i = 0; while (1) { fgets(allInput, sizeof(allInput), stdin); strtok(allInput, "\n"); if (strcmp(allInput, "\n") == 0) { break; } // Split words pWord wordGrp = SpiltWord(allInput); // Calculate Hash Number int wordHash = CalHash(wordGrp); // Store the section to the list if (hashList[wordHash] == NULL) { hashList[wordHash] = wordGrp; } else { // Go to the end of the list TraceList(hashList[wordHash])->nextWord = wordGrp; } i = 0; } char output[100000][10]; int pointer = 0; // Search while (1) { char queryWord[100]; i = 0; void* saver = fgets(queryWord, sizeof(queryWord), stdin); if (saver == NULL) { break; } strtok(queryWord, "\n"); strtok(queryWord, " "); int queryHash = WordHash(queryWord); pWord foundNode = FindMatch(hashList, queryHash, queryWord); if (foundNode) { strcpy(output[pointer++], foundNode->word); } else { strcpy(output[pointer++], "eh"); } } if (pointer != 0) { for (int i = 0; i < pointer; ++ i) { printf("%s\n", output[i]); } } return 0; }