main.cpp
2.48 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
127
128
129
130
131
132
133
134
135
136
#include"Layers.hpp"
#include"SimpleConvNet.hpp"
#include"fstream"
using namespace std;
int main() {
input_dim id = { 3, 32, 32 };
conv_param cp = { 32,32,64, 3,1,1 };
SimpleConvNet SCN(id, cp);
freopen("input.txt", "r", stdin);
vector<Mat> X;
int nx = 1, dim = 3, row = 32, col = 32;
double tmp;
for (int i = 0; i < nx; i++) {
vector<double> rev;
for (int d = 0; d < dim; d++) {
for (int r = 0; r < row; r++) {
for (int c = 0; c < col; c++) {
scanf("%lf", &tmp);
rev.push_back(tmp);
}
}
}
X.push_back(Mat(dim, row, col, rev));
}
freopen("pred.txt", "r", stdin);
nx = 2, dim = 3, row = 32, col = 32;
for (int i = 0; i < nx; i++) {
vector<double> rev;
for (int d = 0; d < dim; d++) {
for (int r = 0; r < row; r++) {
for (int c = 0; c < col; c++) {
scanf("%lf", &tmp);
rev.push_back(tmp);
}
}
}
X.push_back(Mat(dim, row, col, rev));
}
auto x = SCN.predict(X);
auto pred = SCN.argmax(x);
int num = 0, pd;
char receipt[100];
int total = 0;
ifstream fin;
ofstream fout;
fin.open("receipt.txt");
char c;
int cnt=0;
while(fin.get(c)){
receipt[cnt] = c;
cnt++;
}
fin.close();
fout.open("receipt.txt");
for(int i=0; i<cnt; i++){
fout << receipt[i];
}
switch(pred[0]){
case 0:
cout << "can\n";
fout << 0;
break;
case 1:
cout << "ramen\n";
fout << 1;
break;
case 2:
cout << "cigarette\n";
fout << 2;
break;
case 3:
cout << "instant rice\n";
fout << 3;
break;
case 4:
cout << "wet tissue\n";
fout << 4;
break;
default:
cout << "try again\n";
break;
}
fout.close();
fin.open("receipt.txt");
cnt=0;
while(fin.get(c)){
receipt[cnt] = c;
cnt++;
}
fin.close();
cout << "\n\n===================receipt===================\n\n\n";
for(int i = 0; i<cnt; i++){
switch(receipt[i]){
case '0':
cout << "can---------------------------------1,200Won\n";
total += 1200;
break;
case '1':
cout << "ramen-------------------------------1,000Won\n";
total += 1000;
break;
case '2':
cout << "cigarette---------------------------4,500Won\n";
total += 4500;
break;
case '3':
cout << "instant rice------------------------1,500Won\n";
total += 1500;
break;
case '4':
cout << "wet tissue--------------------------2,000Won\n";
total += 2000;
break;
default:
break;
}
}
cout << "\nTotal-------------------------------" << total << "Won\n";
cout << "\n\n=============================================\n\n\n";
return 0;
}