@egor2116
450 / 374 / 42
Регистрация: 20.01.2013
Сообщений: 1,133
|
16.01.2014, 10: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
| #include <iostream>
namespace array
{
template< class T >
bool eqauls(const T & left, const T & right)
{
return left == right;
}
template< class T >
int getCountPair(T * arr, const size_t SIZE)
{
int count = 0;
for(size_t i = 0; i < SIZE; ++i)
if(eqauls(arr[i], arr[i + 1]) && i + 1 < SIZE)
++count;
return count;
}
}
int main()
{
size_t SIZE = 0;
std::cout << "Input size array : "; std::cin >> SIZE;
int arr[SIZE];
for(size_t i = 0; i < SIZE; ++i)
{
std::cout << "Input element : "; std::cin >> arr[i];
}
std::cout << "count pair : " << array::getCountPair(arr, SIZE) << std::endl;
system("PAUSE");
return 0;
} |
|
1
|