Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
1413 connectés 

  FORUM HardWare.fr
  Programmation

  le probleme de hanoi

 


 Mot :   Pseudo :  
 
Bas de page
Auteur Sujet :

le probleme de hanoi

n°105688
the big be​n
Posté le 27-02-2002 à 18:03:38  profilanswer
 

:??:  :??:  :??:  :??:  :??:  :??:  :??:  :??:  
Quel qu un peu soit me dire pq ca ne va pas ou me dire ou trouver les sources pour m'aider a résoudre ce probleme !! :??:  
 
 
#include <iomanip.h>
#include <stdlib.h>
const grand = 3;     //nb de données dans le tab de départ
typedef int tableau[grand*2];
class hanoi
{
private:
 tableau tab_dep, tab_posi, tab_neg, tab_temp;
 int top(tableau tab);
 int pop(tableau tab);
 void push(tableau tab,int nb);
 void deplacement(int n,tableau src, tableau dst, tableau temp);
public:
 hanoi(int tab_depart[grand]);
 void select_deplac();
};
hanoi::hanoi(int tab_depart[grand])
{
 for (int i = 0; i < (grand*2)1; ++i) tab_dep[i] = tab_depart[i];
 for (int j = 0; j < grand; ++j) { tab_posi[j]=0; tab_neg[j]=0;  tab_temp[j]=0;}
 tab_dep[grand*2] =grand1; tab_posi[grand*2] =0;  tab_neg[grand*2] =0; tab_temp[grand*2] =0;
}
int hanoi::top(tableau tab)
{
 return tab[grand*2];
}
int hanoi::pop(tableau tab)
{
 -tab[grand*2];
 return tab[tab[grand*2]+1];
}
void hanoi::push(tableau tab,int nb)
{
 tab[tab[grand*2]] = nb;  
 ++tab[grand*2];
}
void hanoi::select_deplac()
{
/* if (top() < 0)  file://negatif
  deplacement(grand, tab_dep, tab_neg, tab_temp);
 else*/
  deplacement(grand, tab_dep, tab_posi, tab_temp);
}
void hanoi::deplacement(int n,tableau src, tableau dst, tableau temp)
{
 if (n == 1)
 {
  cout << "deplacement de src vers dst"<< endl;;
  push(dst,pop(src));
 }
 else
 {  
 // for (int i= 7; i ==0 ; -i)  { cout << setw(3) << src[i] << "   " <<setw(3) << dst[i] << "   " <<setw(3) << temp[i] << endl; }
  deplacement(n1, src, temp, dst);
  deplacement(1, src, dst, temp);
  deplacement(n1, temp, dst, src);
 }
}
 
int main()
{
 int tab_depart[grand];
 tab_depart[0]=1;tab_depart[1]=2;tab_depart[2]=3;
 
 hanoi H(tab_depart);
 H.select_deplac();
 return EXIT_SUCCESS;
}


---------------
Ben
mood
Publicité
Posté le 27-02-2002 à 18:03:38  profilanswer
 

n°105695
Ciler
Posté le 27-02-2002 à 18:21:44  profilanswer
 

Réédite ton message en désactivant les smileys...


---------------
And I looked, and behold a pale horse: and his name that sat on him was Death, and Hell followed with him. Revelations 6:8
n°105715
HelloWorld
Salut tout le monde!
Posté le 27-02-2002 à 19:35:56  profilanswer
 

...
Deja qu'il faut qu'on comprenne ton listing, en plus il faut deviner ce qui va pas ! ???
Précise un peu ce qui cloche !!!
 
pour des sites internet ... une petite recherche en donne beaucoup ...
http://www.programmationworld.com/ [...] ours1.html
...


---------------
FAQ fclc++ - FAQ C++ - C++ FAQ Lite

Aller à :
Ajouter une réponse
  FORUM HardWare.fr
  Programmation

  le probleme de hanoi

 

Sujets relatifs
probleme accessProblème d'en-têtes de mails avec PHP
[JAVASCRIPT] Probleme de reperage d'un objet[SQL] probleme de requetes
phpBB probléme d'inscription!!![PHP] Probleme avec un script
Problème en [GSURfn][delphi] probleme avec les champs de type currency
probleme pour un enregistrmentproblème encodage du contenu d'un formulaire avec php
Plus de sujets relatifs à : le probleme de hanoi


Copyright © 1997-2022 Hardware.fr SARL (Signaler un contenu illicite / Données personnelles) / Groupe LDLC / Shop HFR