Кресты / Говнокод #18125 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
  13. 13
  14. 14
  15. 15
  16. 16
  17. 17
  18. 18
  19. 19
  20. 20
  21. 21
  22. 22
  23. 23
  24. 24
  25. 25
  26. 26
  27. 27
  28. 28
  29. 29
  30. 30
  31. 31
  32. 32
  33. 33
  34. 34
  35. 35
  36. 36
  37. 37
  38. 38
  39. 39
  40. 40
  41. 41
  42. 42
//Башня хаханойская
#include <iostream>
#include<ctime>
#include<math.h>

using namespace std;
int count=0;
void hanoi_towers(int quantity, int from, int to, int buf_peg)   
{
int mass[10];                                                       
if (quantity != 0)
{
hanoi_towers(quantity-1, from, buf_peg, to);
 for (int i = 0; i < quantity; i++) {
mass[i]=1+rand()%quantity;
cout <<" ["<<i<<"]="<<mass[i]<<endl;}
cout <<"S kol'ca # "<< from << " na kol'co # " << to << endl;
hanoi_towers(quantity-1, buf_peg, to, from);
 count++;
}
}

int main()
{
int mas[10];
		int start_peg = 1, destination_peg=3, buffer_peg=2, plate_quantity,p;

		cout << "Koli4estvo discov:" << endl;
		cin  >> plate_quantity;
	   for (int i = 0; i < plate_quantity; i++) {
	   mas[i]=i;
		cout <<"1 massiv=["<<i<<"]="<<mas[i]<<endl;}
		hanoi_towers(plate_quantity, start_peg, destination_peg, buffer_peg);
			 cout<<"Kol. iteracui  = "<<count<<endl;
			  p=pow(2.0,plate_quantity)-1 ;
			 cout<<"Po formule ="<<p<<endl;
for (int i = 0; i < plate_quantity; i++) {
cout <<"3 massiv=["<<i<<"]="<<mas[i]<<endl;
}
getchar();
getchar();
}

//Башня хаханойская

Запостил: ebywku ebywku, (Updated )

Комментарии (4) RSS

      • {
        {
        }
        }
        {
        }
        }
        count++;
        mas[i]=i;
        int main()
        getchar();
        getchar();
        int count=0;
        int mas[10];
        int mass[10];
        #include<ctime>
        #include<math.h>
        if (quantity != 0)
        #include <iostream>
        //Башня хаханойская
        using namespace std;
        cin  >> plate_quantity;
        mass[i]=1+rand()%quantity;
        p=pow(2.0,plate_quantity)-1 ;
        cout<<"Po formule ="<<p<<endl;
        for (int i = 0; i < quantity; i++) {
        cout <<" ["<<i<<"]="<<mass[i]<<endl;}
        cout << "Koli4estvo discov:" << endl;
        cout<<"Kol. iteracui  = "<<count<<endl;
        for (int i = 0; i < plate_quantity; i++) {
        for (int i = 0; i < plate_quantity; i++) {
        cout <<"3 massiv=["<<i<<"]="<<mas[i]<<endl;
        hanoi_towers(quantity-1, from, buf_peg, to);
        hanoi_towers(quantity-1, buf_peg, to, from);
        cout <<"1 massiv=["<<i<<"]="<<mas[i]<<endl;}
        cout <<"S kol'ca # "<< from << " na kol'co # " << to << endl;
        void hanoi_towers(int quantity, int from, int to, int buf_peg)
        int start_peg = 1, destination_peg=3, buffer_peg=2, plate_quantity,p;
        hanoi_towers(plate_quantity, start_peg, destination_peg, buffer_peg);
        Ответить

Добавить комментарий

Я, guest, находясь в здравом уме и твердой памяти, торжественно заявляю:

    А не использовать ли нам bbcode?


    8