@anmartex
...
1708 / 1201 / 497
Регистрация: 12.02.2013
Сообщений: 1,978
|
22.02.2013, 20:29
|
|
Как-то так:
C++ | 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
| #include <iostream>
#include <map>
#include <string>
#include <fstream>
#include <locale>
#include <sstream>
using namespace std;
int main()
{
setlocale(LC_CTYPE, "Russian");
typedef multimap<string, string> strMap;
strMap enru;
strMap::iterator it;
stringstream ss;
string en;
string ru;
ifstream fin("words.txt",ios::in | ios::binary);
string buff;
while (!fin.eof())
{
getline(fin, buff);
ss << buff;
ss >> en >> ru;
enru.insert(make_pair(en,ru));
}
//-----------------------------------------------------------
while (true)
{
cout << "введите слово: ";
getline(cin, buff);
ru.clear();
ss.clear();
ss << buff;
for (ss >> en; !en.empty(); ss >> en)
{
it = enru.find(en);
if (it != enru.end())
{
ru += it->second;
}
else
{
ru += "<UNKNOWN>";
}
ru += " ";
en.clear();
}
cout << "перевод: " << ru << endl;
}
} |
|
Бинарник с исходником: program.7z
0
|