@StailGot
28 / 23 / 6
Регистрация: 25.08.2013
Сообщений: 41
|
25.04.2014, 22:39
|
|
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
| #include <algorithm>
#include <iostream>
#include <iterator>
#include <map>
#include <sstream>
#include <string>
using namespace std;
int main()
{
// карта: длина слова - слово
map<size_t, string> key_map;
string buf;
::getline( cin, buf );
stringstream ss ( move(buf) );
while ( !ss.eof() )
{
ss >> buf;
key_map[buf.length()] = move( buf );
}
// выводим все что есть
for ( auto & word : key_map )
cout << word.first << " " << word.second << endl;
size_t length;
cin >> length;
// выводим слово по указанной длине
cout << key_map[length] << endl;
// меняем слово
cin >> key_map[length];
// проверяем изменения
cout << key_map[length] << endl;
for ( auto & word : key_map )
cout << word.first << " " << word.second << endl;
getchar();
} |
|
0
|