| 175 | } |
| 176 | |
| 177 | void read_nth_digit(const int n, std::vector<float>& digit) |
| 178 | { |
| 179 | const std::string SYMBOLS = "@0#%=+*-. "; |
| 180 | std::ifstream file("../digits.txt"); |
| 181 | const int DIGITS = 10; |
| 182 | const int HEIGHT = 28; |
| 183 | const int WIDTH = 28; |
| 184 | |
| 185 | if(not file.is_open()) |
| 186 | { |
| 187 | return; |
| 188 | } |
| 189 | |
| 190 | for(int d = 0; d < DIGITS; ++d) |
| 191 | { |
| 192 | for(int i = 0; i < HEIGHT * WIDTH; ++i) |
| 193 | { |
| 194 | unsigned char temp = 0; |
| 195 | file.read(reinterpret_cast<char*>(&temp), sizeof(temp)); |
| 196 | if(d == n) |
| 197 | { |
| 198 | float data = temp / 255.0; |
| 199 | digit.push_back(data); |
| 200 | std::cout << SYMBOLS[static_cast<int>(data * 10) % 11]; |
| 201 | if((i + 1) % WIDTH == 0) |
| 202 | std::cout << std::endl; |
| 203 | } |
| 204 | } |
| 205 | } |
| 206 | std::cout << std::endl; |
| 207 | } |