-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path3.1.8.1 Mismatch operations
49 lines (36 loc) · 1.03 KB
/
3.1.8.1 Mismatch operations
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
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int diferense;
struct Compare
{
bool operator()(const int &f, const int &s)
{
diferense = abs(f - s);
return (diferense < 15);
}
};
int main()
{
vector<int> original_values =
{ 210, 314, 202, 110, 211, 302, 358, 229, 260, 411, 412, 311, 373, 483 };
vector<int> noisy_values =
{ 211, 324, 203, 113, 227, 320, 340, 210, 239, 411, 412, 333, 371, 501 };
pair<vector<int>::iterator, vector<int>::iterator> p2;
pair<vector<int>::iterator, vector<int>::iterator> p;
p.first = original_values.begin();
p.second = noisy_values.begin();
do{
p2 = mismatch(p.first, original_values.end(), p.second, Compare());
cout << "First difference greater than " << diferense - 1 << " is found: " << *(p2.first) << " - " << *(p2.second) << endl;
cout << endl;
p.first = p2.first;
std::advance(p.first, 1);
p.second = p2.second;
std::advance(p.second, 1);
}while (p.first != original_values.end()) ;
system("pause");
return 0;
}