Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <windows.h>
- using namespace std;
- int lineCount=0;
- string words[10000];
- string hint;
- void updateList()
- {
- ifstream file("gtb.txt");
- string text;
- while(getline(file,text))
- {
- words[lineCount]+=text;
- lineCount++;
- }
- file.close();
- cout<<"Total Themes Available: "<<lineCount<<endl;
- }
- void repeatCheck()
- {
- string temp, repeatedWordsList="";
- bool repeat=false;
- for(int c=0;c<lineCount;c++)
- {
- for(int x=0;x<lineCount;x++)
- {
- temp=words[c];
- if(temp==words[x]&&x>c)
- {
- repeatedWordsList+=temp;
- repeatedWordsList+=", ";
- repeat=true;
- }
- }
- }
- if(repeat==true)cout<<"Repeated Words Found: "<<repeatedWordsList<<endl;
- }
- int main()
- {
- updateList();
- repeatCheck();
- while(hint!="end")
- {
- cout<<"Hint: ";
- getline(cin,hint);
- system("cls");
- if(hint=="add")
- {
- string newTheme;
- ofstream file("gtb.txt");
- cout<<"Theme to be added: ";
- getline(cin,newTheme);
- for(int c=0;c<lineCount;c++)file<<words[c]<<endl;
- file<<newTheme<<endl;
- cout<<newTheme<<" has been added to the list!"<<endl;
- file.close();
- for(int c=0;c<lineCount;c++)words[c]="";
- lineCount=0;
- updateList();
- repeatCheck();
- }
- else if(hint=="substr")
- {
- string substrHint="";
- cout<<"What is the substring within the hint?: ";
- getline(cin,substrHint);
- system("cls");
- for(int c=0;c<lineCount;c++)if(words[c].find(substrHint)!=string::npos)cout<<words[c]<<endl;
- }
- else if(hint=="remove")
- {
- string wordDelete;
- string deletedWord;
- ofstream file("gtb.txt");
- cout<<"Theme to be removed: ";
- getline(cin,wordDelete);
- for(int c=0;c<lineCount;c++)
- {
- if(words[c]!=wordDelete||words[c]==deletedWord)file<<words[c]<<endl;
- else if(words[c]==wordDelete)deletedWord=words[c];
- }
- cout<<wordDelete<<" has been removed from the list!"<<endl;
- file.close();
- for(int c=0;c<lineCount;c++)words[c]="";
- lineCount=0;
- updateList();
- repeatCheck();
- }
- else if(hint=="undo")
- {
- cout<<"Your last action has been undone!"<<endl;
- }
- for(int c=0;c<lineCount;c++)
- {
- bool possibleWord=true;
- int numOfSpaces=0;
- int tempHSpace=hint.find(' ');
- int tempWSpace=words[c].find(' ');
- int tempHSpace2=hint.find(' ',tempHSpace);
- int tempWSpace2=words[c].find(' ',tempWSpace);
- if(tempHSpace!=-1&&tempWSpace!=-1&&tempHSpace2==-1&&tempWSpace2==-1)numOfSpaces=1;
- else if(tempHSpace!=-1&&tempWSpace!=-1&&tempHSpace2!=-1&&tempWSpace2!=-1)numOfSpaces=2;
- if(hint.length()==words[c].length())
- {
- if(hint.find(' ')==string::npos&&words[c].find(' ')==string::npos)
- {
- for(int x=0;x<hint.length();x++)if(hint[x]!='.'&&hint[x]!=words[c][x])possibleWord=false;
- if(possibleWord==true)cout<<words[c]<<endl;
- }
- else if(numOfSpaces==1)
- {
- int hspace1=hint.find(' ');
- int wspace1=words[c].find(' ');
- if(hspace1==wspace1)
- {
- for(int x=0;x<hint.length();x++)if(hint[x]!='.'&&hint[x]!=' '&&hint[x]!=words[c][x])possibleWord=false;
- if(possibleWord==true)cout<<words[c]<<endl;
- }
- }
- else if(numOfSpaces==2)
- {
- int hspace1=hint.find(' ');
- int wspace1=words[c].find(' ');
- int hspace2=hint.rfind(' ');
- int wspace2=words[c].rfind(' ');
- if(hspace1==wspace1&&hspace2==wspace2)
- {
- for(int x=0;x<hint.length();x++)if(hint[x]!='.'&&hint[x]!=' '&&hint[x]!=words[c][x])possibleWord=false;
- if(possibleWord==true)cout<<words[c]<<endl;
- }
- }
- }
- }
- }
- }
- ///Ideas
- ///Undo last action (adding words)
- ///Delete specific words
- ///Create backup file (Just in case :])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement