-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLetter.h
executable file
·112 lines (95 loc) · 2.47 KB
/
Letter.h
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
//
// Created by temporal on 06.06.2017.
//
#ifndef UNTITLED_LETTER_H
#define UNTITLED_LETTER_H
int const dimention=8;
int const depth=2;
int const finddepth=3;
class Letter{
public:
int image[dimention][dimention];
Letter(int abc[dimention][dimention]){
for (int i = 0; i < dimention; ++i) {
for (int j = 0; j < dimention; ++j) {
image[i][j]=abc[i][j];
}
}
}
Letter(){
for (int i = 0; i < dimention; ++i) {
for (int j = 0; j < dimention; ++j) {
image[i][j]=0;
}
}
}
double compare(int abc[dimention][dimention]){
double score=0;
for (int i = 0; i < dimention; ++i) {
for (int j = 0; j < dimention; ++j) {
if (image[i][j]==abc[i][j]){
score++;
}
}
}
return score/((double)(dimention*dimention));
}
Letter(Letter &second) {
for (int i = 0; i < dimention; ++i) {
for (int j = 0; j < dimention; ++j) {
this->image[i][j]=second.image[i][j];
}
}
}
void fillLetter(){
for (int i = 0; i < dimention; ++i) {
cout<<"введите "<<i<<" строку";
for (int j = 0; j < dimention; ++j) {
cin>>image[i][j];
}
}
}
void fillRandLetter(){
for (int i = 0; i < dimention; ++i) {
for (int j = 0; j < dimention; ++j) {
image[i][j]=rand()%depth;
}
}
}
void showLetter(){
for (int i = 0; i < dimention; ++i) {
for (int j = 0; j < dimention; ++j) {
cout<<image[i][j]<<" ";
}
cout<<endl;
}
cout<<endl<<endl;
}
void readFromFile(string name){
ifstream in;
in.open(name);
for (int i = 0; i < dimention; ++i) {
for (int j = 0; j < dimention; ++j) {
in>>image[i][j];
}
}
in.close();
// delete in;
}
void writeToFile(string name){
ofstream out;
out.open(name,ios::out);
for (int i = 0; i < dimention; ++i) {
for (int j = 0; j < dimention; ++j) {
out<<image[i][j]<< " ";
}
out<<endl;
}
out.close();
// delete out;
}
// ~Letter(){
// delete[] image;
// }
};
#endif //UNTITLED_LETTER_H