@Ev[G]eN
iOS/Android Developer
5114 / 1552 / 383
Регистрация: 23.01.2011
Сообщений: 3,176
|
03.03.2013, 13:57
|
|
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
| #include <algorithm>
#include <iterator>
#include <iostream>
#include <vector>
int main ()
{
int vectorSize;
std::cout << "Enter the size: ";
std::cin >> vectorSize;
std::vector <int> fVector;
std::cout << "Input " << vectorSize << " elements: " << std::endl;
int element;
for (int i = 0; i < vectorSize; ++i) {
std::cin >> element;
fVector.push_back(element);
}
std::vector <int> sVector;
for (auto currNum: fVector)
if (std::count(fVector.begin(), fVector.end(), currNum) > 1 && !std::count(sVector.begin(), sVector.end(), currNum))
sVector.push_back(currNum);
std::cout << "Count of repeating elements: " << sVector.size() << std::endl;
for (auto currNum: sVector)
std::cout << "Element " << currNum << " repeat " << std::count(fVector.begin(), fVector.end(), currNum) << " times!" << std::endl;
return 0;
} |
|
2
|