Я новичок в C ++, программирую всего несколько дней, так что это может показаться глупым, но вы можете определить, почему мои массивы работают неправильно? Это начало программы, которую я разрабатываю, которая решит головоломки Судоку, но двумерный массив, который я использую для ее решения, работает неправильно.
#include <iostream>
#include <string>
using namespace std;
int main () {
char dash[9][9];
for (int array=0; array<9; array++) {
for (int array2=0; array2<9; array2++) {
dash[array][array2]=array2;
cout << dash[array][array2];
}
}
cout << dash[1][4] << endl; //This is temporary, but for some reason nothing outputs when I do this command.
cout << "╔═══════════╦═══════════╦═══════════╗" << endl;
for (int count=0; count<3; count++) {
for (int count2=0; count2<3; count2++) {
cout << "║_" << dash[count][count2*3] << "_|_" << dash[count] [count2*3+1] << "_|_" << dash[count][count2*3+2] << "_";
}
cout << "║" << endl;
}
cout << "╠═══════════╬═══════════╬═══════════╣" << endl;
for (int count=0; count<3; count++) {
for (int count2=0; count2<3; count2++) {
cout << "║_" << dash[count][count2*3] << "_|_" << dash[count] [count2*3+1] << "_|_" << dash[count][count2*3+2] << "_";
}
cout << "║" << endl;
}
cout << "╠═══════════╬═══════════╬═══════════╣" << endl;
for (int count=0; count<3; count++) {
for (int count2=0; count2<3; count2++) {
cout << "║_" << dash[count][count2*3] << "_|_" << dash[count][count2*3+1] << "_|_" << dash[count][count2*3+2] << "_";
}
cout << "║" << endl;
}
cout << "╚═══════════╩═══════════╩═══════════╝" << endl;
return 0;
}
Также я знаю, что могут быть более простые способы создания доски Судоку, но я уже вижу в уме, как она будет работать, и если она не удалась, то единственный способ научиться - это потерпеть неудачу. Все, что я хочу знать, это то, что не так с массивами.