-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcross.cpp
More file actions
55 lines (49 loc) · 999 Bytes
/
cross.cpp
File metadata and controls
55 lines (49 loc) · 999 Bytes
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
//Kattis: Cross
#include<iostream>
#include<string>
#include<vector>
#include<fstream>
#define INF 9999
using namespace std;
int main(){
ifstream inputfile("cross_input2.txt");
string line;
char matrix_original[10][10];
int matrix[10][10];
bitset<10> matrix_bitset;
int row=0,col=0;
if(inputfile.is_open()){
while(getline(inputfile,line)){
col=0;
for(int i=0; i< line.size(); i++){
cout<<line[i]<<" ";
matrix_original[row][col] = line[i];
if(matrix_original[row][col] != '.'){
matrix[row][col] = matrix_original[row][col] - '0';
matrix_bitset[row][col].set(matrix[row][col],1);
}else{
matrix[row][col] = INF;
}
col++;
}
cout<<endl;
row++;
}
}
inputfile.close();
return 0;
}
int validateMatrix(int matrix[][10]){
//validate the box 0-9
bitset<10> temp;
for(int i=0;i<3;i++){
for(int j=0;j<3;j++){
if(matrix[i][j]!=INF){
if(temp.test(matrix[i][j])){
cout<<"ERROR";
exit(1);
}
}
}
}
}