[Résolu] Pouvez-vous m'aider ?
Publié : lun. 23/juil./2012 8:42
Il y a déjà un moment que je creuse et j'ai des problèmes pour trouver la solution.
Voici mon projet : lire un tableau en diagonales normales et inversées.
Voici ce que j'ai fait :
Le problème c'est que ça me limite à un tableau de 6x6 et j'aimerais bien trouver une solution pour pouvoir utiliser n'importe quel tableau.
Je me rends bien compte que ce n'est pas la bonne solution, alors pouvez-vous m'aider s'il vous plait ?
Voici mon projet : lire un tableau en diagonales normales et inversées.
Voici ce que j'ai fait :
Code : Tout sélectionner
X = 0 : Y = 0
If Y = 0
ChaineTrouvee$ = Tableau1(X, Y) ; haut gauche
Rech1 = FindString(ChaineTrouvee$, ChaineATrouver$)
Rech2 = FindString(ReverseString(ChaineTrouvee$), ChaineATrouver$)
If Rech1
Goto DMN
ElseIf Rech2
Goto DDI
EndIf
ChaineTrouvee$ = Tableau1(X+5, Y+5) ; bas droite
Rech1 = FindString(ChaineTrouvee$, ChaineATrouver$)
Rech2 = FindString(ReverseString(ChaineTrouvee$), ChaineATrouver$)
If Rech1
Goto DMN
ElseIf Rech2
Goto DDI
EndIf
EndIf
Y + 1
If Y = 1
ChaineTrouvee$ = Tableau1(X, Y) + Tableau1(X+1, Y-1) ; deuxième ligne, première colonne
Rech1 = FindString(ChaineTrouvee$, ChaineATrouver$)
Rech2 = FindString(ReverseString(ChaineTrouvee$), ChaineATrouver$)
If Rech1
Goto DMN
ElseIf Rech2
Goto DDI
EndIf
ChaineTrouvee$ = Tableau1(X+4, Y+4) + Tableau1(X+5, Y+3) ; avant dernière colonne, avant dernière ligne
Rech1 = FindString(ChaineTrouvee$, ChaineATrouver$)
Rech2 = FindString(ReverseString(ChaineTrouvee$), ChaineATrouver$)
If Rech1
Goto DMN
ElseIf Rech2
Goto DDI
EndIf
EndIf
Y + 1
If Y = 2
ChaineTrouvee$ = Tableau1(X, Y) + Tableau1(X+1, Y-1) + Tableau1(X+2, Y-2)
Rech1 = FindString(ChaineTrouvee$, ChaineATrouver$)
Rech2 = FindString(ReverseString(ChaineTrouvee$), ChaineATrouver$)
If Rech1
Goto DMN
ElseIf Rech2
Goto DDI
EndIf
ChaineTrouvee$ = Tableau1(X+3, Y+3) + Tableau1(X+4, Y+2) + Tableau1(X+5, Y+1)
Rech1 = FindString(ChaineTrouvee$, ChaineATrouver$)
Rech2 = FindString(ReverseString(ChaineTrouvee$), ChaineATrouver$)
If Rech1
Goto DMN
ElseIf Rech2
Goto DDI
EndIf
EndIf
Y + 1
If Y = 3
ChaineTrouvee$ = Tableau1(X, Y) + Tableau1(X+1, Y-1) + Tableau1(X+2, Y-2) + Tableau1(X+3, Y-3)
Rech1 = FindString(ChaineTrouvee$, ChaineATrouver$)
Rech2 = FindString(ReverseString(ChaineTrouvee$), ChaineATrouver$)
If Rech1
Goto DMN
ElseIf Rech2
Goto DDI
EndIf
ChaineTrouvee$ = Tableau1(X+2, Y+2) + Tableau1(X+3, Y+1) + Tableau1(X+4, Y) + Tableau1(X+5, Y-1)
Rech1 = FindString(ChaineTrouvee$, ChaineATrouver$)
Rech2 = FindString(ReverseString(ChaineTrouvee$), ChaineATrouver$)
If Rech1
Goto DMN
ElseIf Rech2
Goto DDI
EndIf
EndIf
Y + 1
If Y = 4
ChaineTrouvee$ = Tableau1(X, Y) + Tableau1(X+1, Y-1) + Tableau1(X+2, Y-2) + Tableau1(X+3, Y-3) + Tableau1(X+4, Y-4)
Rech1 = FindString(ChaineTrouvee$, ChaineATrouver$)
Rech2 = FindString(ReverseString(ChaineTrouvee$), ChaineATrouver$)
If Rech1
Goto DMN
ElseIf Rech2
Goto DDI
EndIf
ChaineTrouvee$ = Tableau1(X+1, Y+1) +Tableau1(X+2, Y) + Tableau1(X+3, Y-1) + Tableau1(X+4, Y-2) + Tableau1(X+5, Y-3)
Rech1 = FindString(ChaineTrouvee$, ChaineATrouver$)
Rech2 = FindString(ReverseString(ChaineTrouvee$), ChaineATrouver$)
If Rech1
Goto DMN
ElseIf Rech2
Goto DDI
EndIf
EndIf
Y + 1
If Y = 5
ChaineTrouvee$ = Tableau1(X, Y) + Tableau1(X+1, Y-1) +Tableau1(X+2, Y-2) + Tableau1(X+3, Y-3) + Tableau1(X+4, Y-4) + Tableau1(X+5, Y-5)
Rech1 = FindString(ChaineTrouvee$, ChaineATrouver$)
Rech2 = FindString(ReverseString(ChaineTrouvee$), ChaineATrouver$)
If Rech1
Goto DMN
ElseIf Rech2
Goto DDI
EndIf
EndIf
Je me rends bien compte que ce n'est pas la bonne solution, alors pouvez-vous m'aider s'il vous plait ?