I have to write a program where I input a word such as "BANANA" and it will read from a text file(this is a modified version of what i am actually working on) containing this
Text File:
BANANA TA GG GZ 95 5G
APPLE AF GC CF CG CA
ORANGE CG CG VG GL CD
GRAPE CG CG VG GL CD
In console i will input:
BANANA or banana
And i get:
Code: TA GG GZ 95 5G
But where I am stuck right now is when I input Orange I want to get
I just realized you purposely want two-way lookup. Do you have access to boost (bi-directional map)? Or you could make custom class that links map<a,b> with a map<b,a>.
Edit: nevermind, since the reverse would make it not have unique keys. Not sure which data structure to use for the reverse... How many items are we talking about?
Uses a map<string,string> to store fruit to the "rest" (code).
Uses a map<string,int> to track frequency of "rest". Only if search term's "rest" has turned up more than once, then a full pass of the original map is done to spit out all similar fruits.