hello ..
i have this problem i wanna find out how to do it :
for example : if a have a list of ( incorrect words ):
nce //should be nice // one letter missing
heree // should be here // one letter added
hte // should be the // two letters reversed
here is the methods i need to follow to solve the previous situations :
- One letter missing. You assume that one letter has been left out of the word. You can assemble new words to check by adding letters a..z in each of the positions in the word from the start to the end of the word.
- One letter added. You assume the word has an extra letter. You scan through the word deleting each of the letters in turn, and looking up the word formed by the remaining letters.
- Two letters reversed. You swap letters in positions 0..1, 1..2, 2..3, ... , n-2..n-1, to form new words which you look up.
here is what i have so far :
Code:
1 char string[20];
2 char temp[20];
3 int i;
4 int l=strlen(string);
5
6 for(i=0;i<l/2;i++0){
7 temp = string[i];
8 string[i] = string[l-i];
9 string[l-i] = temp;
10 }
which is method # 3
i cannot think about #1 or #1
please help me how to do it
thank you