-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprogram.cpp
More file actions
95 lines (85 loc) · 1.67 KB
/
program.cpp
File metadata and controls
95 lines (85 loc) · 1.67 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
#include<iostream>
#include<ctime>
#include<vector>
#include<cstdlib>//¦³ªºcompiler¤£¥Îinclude
#include<iomanip>
#include<string>
using namespace std;
void Print(int o);
#include"COLOR.cpp"
#include"DEFINE.h"
bool data[sectors][sectorSize] = {};
int count[sectors] = {};
int main(){
srand (time(NULL));
int total = 0;
for(int i = 0;i < sectors;i++){
for(int j = 0;j < sectorSize;j++){
if(!(rand() % errorRate)){
data[i][j] = 1;
++count[i];
}
}
total += count[i];
}
Print(4);
cout << "Total error: " << total << endl;
cout << "error rate = " << fixed << setprecision(2) << (double)total / sectors * sectorSize << "%" << endl;
}
void Print(int o){
string out;
out += "£s = ";
out += (o + 48);
cout << out << endl;
int check = 0;
int temp;
string edge, edgeB;
for(int i = 0;i < sectorSize;++i){
edge += "-";
edgeB += "=";
}
for(int i = 0;i < sectors;++i){
SetColor(colorOfEdge*16);
cout << "=";
if(i % o == 0){
//SetColor(colorOfEdge*16);
cout << edgeB;
}
else{
SetColor();
cout << edge;
}
SetColor(colorOfEdge*16);
cout << "=" << endl;
cout << "|";
for(int j = 0;j < sectorSize;++j){
if(data[i][j])
SetColor(errorColor*16);
else
SetColor(normalColor*16);
cout << " ";
SetColor();
}
SetColor(colorOfEdge*16);
cout << "|";
SetColor();
if(check == i){
temp = 0;
for(int j = check;j < i + o;++j){
temp += count[j];
}
cout << " This part has ";
if(temp > o)
SetColor(errorColor);
cout << temp;
SetColor();
cout << " errors.";
check += o;
}
cout << endl;
}
SetColor(colorOfEdge*16);
cout << "=" << edgeB << "=" << endl;
SetColor();
cout << edge << endl;
}