-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathErrorCorrection.cpp
More file actions
51 lines (47 loc) · 1.45 KB
/
ErrorCorrection.cpp
File metadata and controls
51 lines (47 loc) · 1.45 KB
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
#include <iostream>
#include <vector>
using namespace std;
int main(){
int n,x;
int soma[200] = {};
int countL = 0,countC = 0;
int l,c;
while (!cin.eof())
{
if(cin >> n){
if(n == 0)
return 0;
//Armazena ordenadamente
for (int i = 0; i < n; ++i)
{
for (int j = 0; j < n; ++j){
cin >> x;
soma[i] += x;
soma[j+n] += x;
}
}
countL = countC = 0;
for (size_t i = 0; i < 200; i++)
if(soma[i] % 2 != 0)
{
if(i >= n){
countC++;
c = i-n+1;
}
else{
countL++;
l = i+1;
}
}
if(countC == 0 && countL == 0)
cout << "OK" << endl;
else if(countC == 1 && countL == 1)
cout << "Change bit (" << l << "," << c << ")" << endl;
else{
cout << "Corrupt" << endl;
}
for (size_t i = 0; i < 200; i++)
soma[i] = 0;
}
}
}