-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWrite_PCN.cpp
More file actions
59 lines (51 loc) · 1.47 KB
/
Write_PCN.cpp
File metadata and controls
59 lines (51 loc) · 1.47 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
using std::cout;
using std::cin;
using std::endl;
using std::vector;
using std::string;
using std::fstream;
using std::ifstream;
using std::ofstream;
int Write_PCN(string filename, Vec_2D Pol_Comp_o){
ofstream output_file(filename);
int no_active = 0;
int a = 1, b = 21;
if(output_file.is_open()){
output_file << Pol_Comp_o[0].size() << endl << Pol_Comp_o.size() <<endl;
for(int i = 0; i < Pol_Comp_o.size(); i++){
no_active = 0;
for (int j = 0; j < Pol_Comp_o[i].size(); j++){
if(Pol_Comp_o[i][j] != DC){
no_active++;
}
}
output_file << no_active << " ";//Show the number of non-don't care variables
for (int j = 0; j < Pol_Comp_o[i].size(); j++){
if(Pol_Comp_o[i][j] == Positive){
if(j < (Pol_Comp_o[i].size() - 1)){//Adjustments to avoid spaces at the EOL
output_file << j + 1 << " ";
}
else{
output_file << j + 1;
}
}
else if(Pol_Comp_o[i][j] == Negative){
if(j < (Pol_Comp_o[i].size() - 1)){//Adjustments to avoid spaces at the EOL
output_file << (j + 1)*(-1) << " ";
}
else{
output_file << (j + 1)*(-1);
}
}
}
if(i < (Pol_Comp_o.size() - 1)){
output_file << endl;
}
}
}
else{
cout<<"\n Error in opening O/P File";
}
output_file.close();
return 0;
}