Otra propuesta de código:
Código (cpp) [Seleccionar]
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <map>
using namespace std;
int main()
{
unsigned int i;
string str;
vector <string> texto;
map<string,string> Diccionario;
Diccionario["coche"] = "car";
Diccionario["hola"] = "hello";
Diccionario["perro"] = "dog";
Diccionario["casa"] = "house";
Diccionario["ciudad"] = "city";
Diccionario["cielo"] = "sky";
Diccionario["vaca"] = "cow";
Diccionario["ojos"] = "eyes";
cout << "Que quiere traducir?: ";
getline(cin, str);
stringstream is(str);
while(is >> str) texto.push_back(str);
cout <<"Las palabras que pusiste son: " << endl;
for (i = 0; i < texto.size(); i++)
cout << i + 1 << ". " << texto[i] << endl;
cout << endl;
for(i = 0; i < texto.size(); i++)
cout << texto[i] << " en ingles es " << Diccionario[texto[i]] << endl;
cin.get();
return 0;
}