关于我的文科班,我们被派到这里,用文字文件制作一个 english to spanish translation:。
至今,我转而去了,但当我执行该方案时,言辞已经ming,我说,每条线上都用多字眼,就是破坏它。
#include<iostream>
#include<string>
#include<fstream>
using namespace std;
class transl
{ private:
class word
{ public:
string eng_word,
spa_word;
word * next,
* prev;
word(string engl_word, string span_word, word * next1 = NULL, word * prev1 = NULL)
{ eng_word = engl_word;
spa_word = span_word;
next = next1;
prev = prev1; }
};
word * head,
* tail;
public:
transl::transl()
{ head = NULL;
tail = NULL; }
transl::~transl()
{ word * wordPtr, * nextWord;
wordPtr = head;
if(head == NULL)
return;
while(wordPtr != NULL)
{ nextWord = wordPtr->next;
delete wordPtr;
wordPtr = nextWord; }
}
void insert(string engl_word, string span_word)
{ if(head == NULL)
head = new word(engl_word, span_word);
else
{ word * wordPtr;
wordPtr = head;
while(wordPtr->next != NULL)
{ wordPtr->next->prev = wordPtr;
wordPtr = wordPtr->next; }
wordPtr->next = new word(engl_word, span_word);
cout << wordPtr->next->eng_word << " " << wordPtr->next->spa_word << endl; }
}
string search(string engl_word)
{ return "Hello"; }
};
int main()
{ ifstream inFile; inFile.open("dictionary.txt");
string engl_word, span_word;
transl test;
if (!inFile)
{ cout << "ERROR! CANNOT LOCATE DICTIONARY!" << endl;
system("pause");
return 1; }
cout << "Loading Dictionary: ";
while(inFile >> engl_word >> span_word)
{ test.insert(engl_word, span_word); }
cout << "Done!" << endl;
system("pause");
system("CLS");
cout << "Translate: ";
cin >> engl_word;
cout << "The translation of " << engl_word << " is " << test.search(engl_word) << . << endl;
system("pause");
return 0; }
例如:
peor wound
la herida
wounded herida
Done!
Press any key to continue . . .
任何人是否知道适当插入价值观的程序