BoneDaddy
2008-01-30, 16:54:04
Ich stehe gerade wirklich auf dem Schlauch. Ich möchte zur Lösung des 8-Dame Problems ein 2 Dimensionales Bool-Arrays mit false initialiseren. Allerdings kommt dabei nur schrott heraus.
Denn Anstatt von Einsen und Nullen bzw. nur Nullen, bekommen ich die verschiedensten Zahlen heraus.
#include <iostream>
#include <sstream>
using namespace std;
class uebung3 {
int field_size_x;
int field_size_y;
bool field[8][8];
void init(int x, int y) {
for(int i=0; i < y; i++) {
for(int j=0; j < x; j++) {
field[y][x] = false;
}
}
}
void printa() {
for(int i=0; i < field_size_y; i++) {
for(int j=0; j < field_size_x; j++) {
cout << field[j][i] << " ";
}
cout << "\n";
}
}
Denn Anstatt von Einsen und Nullen bzw. nur Nullen, bekommen ich die verschiedensten Zahlen heraus.
#include <iostream>
#include <sstream>
using namespace std;
class uebung3 {
int field_size_x;
int field_size_y;
bool field[8][8];
void init(int x, int y) {
for(int i=0; i < y; i++) {
for(int j=0; j < x; j++) {
field[y][x] = false;
}
}
}
void printa() {
for(int i=0; i < field_size_y; i++) {
for(int j=0; j < field_size_x; j++) {
cout << field[j][i] << " ";
}
cout << "\n";
}
}