Programlama | Programlama Dilleri | C Programlama Dili |C++

Anasayfa Programlama C++ Builder Dört At Problemi ve Simülasyonu


Dört At Problemi ve Simülasyonu

C++ Builder 6 ile uyumludur.

AÇIKLAMA

Bu proje 3*3 bir matriste bulunan konumları kullanıcı tarafından belirlenen 2 adet siyah ve 2 adet beyaz atın satranç kuralları dahilinde(at hareketine göre atlar üst üste gelmeyecek şekilde) yer değiştirme işlemini çözen ve at hareketlerini simülasyon ile gösteren programdır.

Programda öncelikli olarak siyah ve beyaz atları karelere sürükleyip bırakın daha sonra program siyah ile beyaz atların yerlerini değiştirecektir.

Programın Tamamını Aşağıdaki Linkten İndirebilirsiniz

Linki Görebilmeniz İçin Üye Olmanız Gerekmektedir...

Üye Kayıt

 Program Kodu:

Parça1;

  1. //---------------------------------------------------------------------------
  2.  
  3. #include <vcl.h>
  4. #pragma hdrstop
  5.  
  6. #include "Unit1.h"
  7. //---------------------------------------------------------------------------
  8. #pragma package(smart_init)
  9. #pragma resource "*.dfm"
  10. TForm1 *Form1;
  11. //---------------------------------------------------------------------------
  12. __fastcall TForm1::TForm1(TComponent* Owner)
  13.         : TForm(Owner)
  14. {
  15.  
  16. }
  17. //---------------------------------------------------------------------------
  18.  
  19.      int yukari()
  20.  {
  21.  
  22.      Form1->Image20->Top-=5;
  23.  }
  24.           int asagi()
  25.  {
  26.  
  27.      Form1->Image20->Top+=5;
  28.  }
  29.       int saga()
  30.  {
  31.  
  32.      Form1->Image20->Left+=5;
  33.  }
  34.       int sola()
  35.  {
  36.  
  37.      Form1->Image20->Left-=5;
  38.  }
  39.  int al=0; int ak=0;
  40.  int a=0; int b=0;   int c=0; int d=0;  int e=0;  int f=0;  int z=0;
  41. void __fastcall TForm1::FormCreate(TObject *Sender)
  42. {     Image20->Visible=false;            Image20->Name="ad";
  43. BitBtn1->Enabled=false;
  44. Image5->Enabled=false;          Image11->Enabled=false;
  45. Image1->Picture=Image11->Picture;
  46. Image2->Picture=Image11->Picture;
  47. Image3->Picture=Image11->Picture;
  48. Image4->Picture=Image11->Picture;
  49. Image6->Picture=Image11->Picture;
  50. Image7->Picture=Image11->Picture;
  51. Image8->Picture=Image11->Picture;
  52. Image9->Picture=Image11->Picture;
  53. Image1->DragMode=dmAutomatic;
  54. Image2->DragMode=dmAutomatic;
  55. Image3->DragMode=dmAutomatic;
  56. Image4->DragMode=dmAutomatic;
  57. Image6->DragMode=dmAutomatic;
  58. Image7->DragMode=dmAutomatic;
  59. Image8->DragMode=dmAutomatic;
  60. Image9->DragMode=dmAutomatic;
  61. Image10->DragMode=dmAutomatic;
  62. Image11->DragMode=dmAutomatic;
  63. Image12->DragMode=dmAutomatic;
  64.  
  65.  
  66. }
  67.  
  68. //---------------------------------------------------------------------------
  69. void __fastcall TForm1::Image1DragDrop(TObject *Sender, TObject *Source,
  70.       int X, int Y)
  71. {
  72. if(Source==Image10 && a!=2)
  73. {  Image1->Tag=1;
  74.    Image1->Picture=Image10->Picture;
  75.    Image1->Enabled=false;
  76.    Image2->Enabled=false;
  77.    Image4->Enabled=false;
  78.    Image6->Enabled=false;
  79.    Image8->Enabled=false; a++;
  80. }
  81. if(Source==Image12 && b!=2)
  82. {  Image1->Tag=2;
  83.    Image1->Picture=Image12->Picture;
  84.    Image2->Enabled=false;
  85.    Image1->Enabled=false;
  86.    Image4->Enabled=false;
  87.    Image6->Enabled=false;
  88.    Image8->Enabled=false; b++;
  89. }
  90. if (a==2 && b==2)
  91.   BitBtn1->Enabled=true;
  92. }
  93. //---------------------------------------------------------------------------
  94. void __fastcall TForm1::Image1DragOver(TObject *Sender, TObject *Source,
  95.       int X, int Y, TDragState State, bool &Accept)
  96. {
  97. Accept=true;
  98. }
  99. //---------------------------------------------------------------------------
  100. void __fastcall TForm1::Image3DragDrop(TObject *Sender, TObject *Source,
  101.       int X, int Y)
  102. {
  103. if(Source==Image10 && a!=2)
  104. {  Image3->Tag=1;
  105.    Image3->Picture=Image10->Picture;
  106.    Image3->Enabled=false;
  107.    Image2->Enabled=false;
  108.    Image4->Enabled=false;
  109.    Image6->Enabled=false;
  110.    Image8->Enabled=false; a++;
  111. }
  112. if(Source==Image12 && b!=2)
  113. {  Image3->Tag=2;
  114.    Image3->Picture=Image12->Picture;
  115.    Image3->Enabled=false;
  116.    Image2->Enabled=false;
  117.    Image4->Enabled=false;
  118.    Image6->Enabled=false;
  119.    Image8->Enabled=false; b++;
  120. }
  121. if (a==2 && b==2)
  122.   BitBtn1->Enabled=true;
  123. }
  124. //---------------------------------------------------------------------------
  125. void __fastcall TForm1::Image7DragDrop(TObject *Sender, TObject *Source,
  126.       int X, int Y)
  127. {
  128. if(Source==Image10 && a!=2)
  129. {  Image7->Tag=1;
  130.    Image7->Picture=Image10->Picture;
  131.    Image7->Enabled=false;
  132.    Image2->Enabled=false;
  133.    Image4->Enabled=false;
  134.    Image6->Enabled=false;
  135.    Image8->Enabled=false; a++;
  136. }
  137. if(Source==Image12 && b!=2)
  138. {  Image7->Tag=2;
  139.    Image7->Picture=Image12->Picture;
  140.    Image7->Enabled=false;
  141.    Image2->Enabled=false;
  142.    Image4->Enabled=false;
  143.    Image6->Enabled=false;
  144.    Image8->Enabled=false; b++;
  145. }
  146. if (a==2 && b==2)
  147.   BitBtn1->Enabled=true;
  148. }
  149. //---------------------------------------------------------------------------
  150. void __fastcall TForm1::Image9DragDrop(TObject *Sender, TObject *Source,
  151.       int X, int Y)
  152. {
  153. if(Source==Image10 && a!=2)
  154. {  Image9->Tag=1;
  155.    Image9->Picture=Image10->Picture;
  156.    Image2->Enabled=false;
  157.    Image9->Enabled=false;
  158.    Image4->Enabled=false;
  159.    Image6->Enabled=false;
  160.    Image8->Enabled=false; a++;
  161. }
  162. if(Source==Image12 && b!=2)
  163. {  Image9->Tag=2;
  164.    Image9->Picture=Image12->Picture;
  165.    Image9->Enabled=false;
  166.    Image2->Enabled=false;
  167.    Image4->Enabled=false;
  168.    Image6->Enabled=false;
  169.    Image8->Enabled=false; b++;
  170. }
  171. if (a==2 && b==2)
  172.   BitBtn1->Enabled=true;
  173. }
  174. //---------------------------------------------------------------------------
  175. void __fastcall TForm1::Image2DragDrop(TObject *Sender, TObject *Source,
  176.       int X, int Y)
  177. {
  178. if(Source==Image10 && a!=2)
  179. {  Image2->Tag=1;
  180.    Image2->Picture=Image10->Picture;
  181.    Image2->Enabled=false;
  182.    Image1->Enabled=false;
  183.    Image3->Enabled=false;
  184.    Image7->Enabled=false;
  185.    Image9->Enabled=false; a++;
  186. }
  187. if(Source==Image12 && b!=2)
  188. {  Image2->Tag=2;
  189.    Image2->Picture=Image12->Picture;
  190.    Image2->Enabled=false;
  191.    Image1->Enabled=false;
  192.    Image3->Enabled=false;
  193.    Image7->Enabled=false;
  194.    Image9->Enabled=false; b++;
  195. }
  196. if (a==2 && b==2)
  197.   BitBtn1->Enabled=true;
  198. }
  199. //---------------------------------------------------------------------------
  200. void __fastcall TForm1::Image4DragDrop(TObject *Sender, TObject *Source,
  201.       int X, int Y)
  202. {
  203. if(Source==Image10 && a!=2)
  204. {  Image4->Tag=1;
  205.    Image4->Picture=Image10->Picture;
  206.    Image4->Enabled=false;
  207.    Image1->Enabled=false;
  208.    Image3->Enabled=false;
  209.    Image7->Enabled=false;
  210.    Image9->Enabled=false; a++;
  211. }
  212. if(Source==Image12 && b!=2)
  213. {  Image4->Tag=2;
  214.    Image4->Picture=Image12->Picture;
  215.    Image4->Enabled=false;
  216.    Image1->Enabled=false;
  217.    Image3->Enabled=false;
  218.    Image7->Enabled=false;
  219.    Image9->Enabled=false; b++;
  220. }
  221. if (a==2 && b==2)
  222.   BitBtn1->Enabled=true;
  223. }
  224. //---------------------------------------------------------------------------
  225. void __fastcall TForm1::Image6DragDrop(TObject *Sender, TObject *Source,
  226.       int X, int Y)
  227. {
  228. if(Source==Image10 && a!=2)
  229. {  Image6->Tag=1;
  230.    Image6->Picture=Image10->Picture;
  231.    Image6->Enabled=false;
  232.    Image1->Enabled=false;
  233.    Image3->Enabled=false;
  234.    Image7->Enabled=false;
  235.    Image9->Enabled=false; a++;
  236. }
  237. if(Source==Image12 && b!=2)
  238. {  Image6->Tag=2;
  239.    Image6->Picture=Image12->Picture;
  240.    Image6->Enabled=false;
  241.    Image1->Enabled=false;
  242.    Image3->Enabled=false;
  243.    Image7->Enabled=false;
  244.    Image9->Enabled=false; b++;
  245. }
  246. if (a==2 && b==2)
  247.   BitBtn1->Enabled=true;
  248. }
  249. //---------------------------------------------------------------------------

 SONRAKİ SAYFA

 

Yorumlar (0)
Sadece kayıtlı kullanıcılar yorum yazabilir!
Son Güncelleme ( Salı, 07 Ağustos 2012 23:12 )