-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherror correction.cpp
More file actions
126 lines (115 loc) · 1.35 KB
/
error correction.cpp
File metadata and controls
126 lines (115 loc) · 1.35 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#include<vector>
#include<iostream>
#define MAXLINE 10
using namespace std;
int ou(int n)
{
if((n%2)==0)
return 1;
else
return 0;
}
int panduan(int a[MAXLINE][MAXLINE],int m)
{
int s;
s=0;
for(int i=0;i<m;i++)
{
int sum;
sum=0;
for(int j=0;j<m;j++)
{
sum=sum+a[i][j];
}
if(ou(sum))
s=s+0;
else
{
//cout<<"no"<<endl;
return 0;
}
//return 0;
}
for(int i=0;i<m;i++)
{
int sum=0;
for(int j=0;j<m;j++)
{
sum=a[j][i]+sum;
}
if(ou(sum))
s=s+0;
else
{
//cout<<"no"<<endl;
return 0;
}
}
if(s==0)
{
//cout<<"yes"<<endl;
return 1;
}
}
int correct(int a[MAXLINE][MAXLINE],int m)
{
int j=0;
int i=0;
for(;i<m;i++)
{
for(;j<m;)
{
if(a[i][j]==0)
{
a[i][j]=1;
int n=panduan(a,m);
if(n==1)
{
cout<<i<<" "<<j<<endl;
goto gobreak;
}
else
j++;
}
else
{
a[i][j]=0;
int n=panduan(a,m);
if(n==1)
{
cout<<i<<" "<<j<<endl;
goto gobreak;
}
else
j++;
}
}
gobreak:
break;
}
if((i==m)&&(j==m))
{
cout<<"no way"<<endl;
}
}
int main(int argc,char* argv[])
{
int a[MAXLINE][MAXLINE];
int n;
cout<<"input n:";
cin>>n;
for(int i=0;i<n;i++)
{
for(int j=0;j<n;j++)
{
cin>>a[i][j];
}
}
if(panduan(a,n))
cout<<"right"<<endl;
else
{
cout<<"wrong"<<endl;
correct(a,n);
}
}