Haevelin
Tripel-As
Dabei seit: 04.06.2013
Beiträge: 221
|
|
Hallo, ich habe ein Kreuzworträtsel in einem Feld. Jetzt soll das Feld so reduziert werden, dass das Kreuzworträtsel genau reinpasst. Dazu habe ich ein Programm geschrieben, dass vier Punkte bestimmt: den äusserst rechten und linken Rand, äusserst oben und unten.
int x=100;
int y=100;
int a=0;
int b=0;
for (int j=0; j< al_kompression.get(i).length; j++){
for (int h=0; h< al_kompression.get(i).length; h++){
if (al_kompression.get(i)[j][h]!='1'){
if (h<x){
x=h;
y=j;
}
}
if ((h==al_kompression.get(i).length-1 && al_kompression.get(i)[j][h]!='1') || (h<al_kompression.get(i).length-1 && al_kompression.get(i)[j][h]!='1'
&& al_kompression.get(i)[j][h+1]=='1')){
if (h>b){
a=j;
b=h;
}
}
}
} // ende j
int x1=100;
int y1=100;
int a1=0;
int b1=0;
for (int j=0; j< al_kompression.get(i).length; j++){
for (int h=0; h< al_kompression.get(i).length; h++){
if (al_kompression.get(i)[h][j]!='1'){
if (h<x1){
x1=h;
y1=j;
}
}
if ((h==al_kompression.get(i).length-1 && al_kompression.get(i)[h][j]!='1')||(h<al_kompression.get(i).length-1 && al_kompression.get(i)[h][j]!='1' &&
al_kompression.get(i)[h+1][j]=='1')){
if (h>a1){
a1=h;
b1=j;
}
}
}
} // ende j
Das Programm funktioniert aber nicht.
Folgende Ausgabe:
H U N G E R 1 1 1
1 1 1 1 S 1 1 1 1
1 1 1 1 S 1 1 1 1
M A T S E 1 1 1 1
1 1 1 1 N E T T 1
1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1
Es folgen die Grenzen
0 0
4 7
0 0
4 4
Dieser Beitrag wurde 1 mal editiert, zum letzten Mal von Haevelin: 11.05.2016 09:43.
|
|