#include #include #include #include using namespace std; int main (void) { bool writeDown=true; int i=0; //For Query.in int wordnumber=0; int amountOfWords=1; int Word=0; //For text.in int Sentencenumber=0; int amountOfSentences=1; int Sentence=0; bool print0=true; FILE *INPUT; INPUT = fopen( "query.in", "r"); //checks how many lines while (!feof(INPUT)) { char temphold=fgetc(INPUT); if (temphold == ' ') {amountOfWords++;} } fclose(INPUT); INPUT = fopen( "query.in", "r"); //Words which user searches for string wordlist[amountOfWords]; int storeaddress[amountOfWords]; wordlist[0]=" "; i=0; wordnumber=0; while (!feof(INPUT)) { char temphold; temphold= fgetc(INPUT); if( temphold >= 97 && temphold <= 122) {temphold = toupper(temphold);} if( temphold == '\n') { break; } if( temphold == ' ') { wordlist[wordnumber]=wordlist[wordnumber]+" "; wordnumber++; } i++; wordlist[wordnumber]=wordlist[wordnumber]+temphold; } fclose(INPUT); INPUT = fopen("text.in","r"); while (!feof(INPUT)) { char temphold=fgetc(INPUT); if (temphold == '.' ) {amountOfSentences++;} } string sentencelist[amountOfSentences]; sentencelist[0]=" "; fclose(INPUT); INPUT = fopen("text.in","r"); while (!feof(INPUT)) { char temphold; temphold= fgetc(INPUT); if( temphold >= 97 && temphold <= 122) {temphold = toupper(temphold);} if (temphold == '.' ) { sentencelist[Sentencenumber] = sentencelist[Sentencenumber]+" "; Sentencenumber++; } else { sentencelist[Sentencenumber]=sentencelist[Sentencenumber]+temphold; } i++; } wordlist[amountOfWords-1]= wordlist[amountOfWords-1] + " " ; //DONE WITH READING /* cout << sentencelist[0]<< "\n\n"; cout << sentencelist[1]<< "\n\n"; cout << sentencelist[2]<< "\n\n"; cout << sentencelist[3]<< "\n\n"; cout << sentencelist[4]<< "\n\n"; cout << sentencelist[5]<< "\n\n"; cout << sentencelist[6]<< "\n\n"; cout << sentencelist[7]<< "\n\n"; cout << wordlist[0]<< "\n\n"; cout << wordlist[1]<< "\n\n"; cout << wordlist[2]<< "\n\n"; cout << amountOfWords<< "\n\n"; */ fclose(INPUT); INPUT = fopen("query.out","w"); while(Sentence < amountOfSentences) { writeDown=true; Word=-1; i=0; while(Word < amountOfWords-1) { i++; Word++; //cout << Word ; //cout << sentencelist[Sentence].find(wordlist[Word]) << " "; if( sentencelist[Sentence].find(wordlist[Word]) != string::npos ) { int x=0; storeaddress[i]=sentencelist[Sentence].find(wordlist[Word]); while(x