fork download
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4.  
  5. string chessBoardMatrix[8][8];
  6. char verticalPositions[8]={'A','B','C','D','E','F','G','H'};
  7. string star="*******" , dot="%%%%%%%";
  8.  
  9. void setBoardStructure()
  10. {
  11. for(int i=0; i<8; i++)
  12. {
  13. if(i%2==0)
  14. {
  15. for(int j=0 ; j<8; j++)
  16. {
  17. if(j%2==0)
  18. {
  19. chessBoardMatrix[i][j]=star;
  20. }
  21. else
  22. {
  23. chessBoardMatrix[i][j]=dot;
  24. }
  25. }
  26. }
  27.  
  28. else
  29. {
  30. for(int j=0 ; j<8; j++)
  31. {
  32. if(j%2!=0)
  33. {
  34. chessBoardMatrix[i][j]=star;
  35. }
  36. else
  37. {
  38. chessBoardMatrix[i][j]=dot;
  39. }
  40. }
  41. }
  42. }
  43. }
  44.  
  45. void drawGameBoard()
  46. {
  47. cout<<"\n\n";
  48.  
  49. cout<<"\t\t 0 1 2 3 4 5 6 7 \n";
  50. cout<<"\t\t ----------------------------------------------------------------- \n";
  51.  
  52. for(int i=0; i<8; i++)
  53. {
  54. cout<<"\t\t"<<verticalPositions[i]<<" |";
  55.  
  56. if(i%2==0)
  57. {
  58. for(int j=0 ; j<8; j++)
  59. {
  60. if(j%2==0)
  61. {
  62. cout<<chessBoardMatrix[i][j]<<"|";
  63. }
  64. else
  65. {
  66. cout<<chessBoardMatrix[i][j]<<"|";
  67. }
  68.  
  69. if(j==7)
  70. {
  71. cout<<" "<<verticalPositions[i];
  72. }
  73. }
  74. }
  75.  
  76. else
  77. {
  78. for(int j=0 ; j<8; j++)
  79. {
  80. if(j%2!=0)
  81. {
  82. cout<<chessBoardMatrix[i][j]<<"|";
  83. }
  84. else
  85. {
  86. cout<<chessBoardMatrix[i][j]<<"|";
  87. }
  88.  
  89. if(j==7)
  90. {
  91. cout<<" "<<verticalPositions[i];
  92. }
  93. }
  94.  
  95.  
  96. }
  97. cout<<endl;
  98. cout<<"\t\t ----------------------------------------------------------------- \n";
  99.  
  100. }
  101. cout<<"\t\t 0 1 2 3 4 5 6 7 \n";
  102.  
  103.  
  104.  
  105. cout<<"\n\n";
  106. }
  107.  
  108.  
  109.  
  110. int main()
  111. {
  112. setBoardStructure();
  113. drawGameBoard();
  114. drawGameBoard();
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.  
  137.  
  138.  
  139.  
  140.  
  141.  
  142.  
  143.  
  144.  
  145.  
  146.  
  147.  
  148.  
  149.  
  150.  
  151.  
  152.  
  153.  
  154.  
  155.  
  156. return 0;
  157. }
  158.  
Success #stdin #stdout 0s 4684KB
stdin
Standard input is empty
stdout

		      0       1       2       3       4       5       6       7   
		   -----------------------------------------------------------------   
		A  |*******|%%%%%%%|*******|%%%%%%%|*******|%%%%%%%|*******|%%%%%%%| A
		   -----------------------------------------------------------------   
		B  |%%%%%%%|*******|%%%%%%%|*******|%%%%%%%|*******|%%%%%%%|*******| B
		   -----------------------------------------------------------------   
		C  |*******|%%%%%%%|*******|%%%%%%%|*******|%%%%%%%|*******|%%%%%%%| C
		   -----------------------------------------------------------------   
		D  |%%%%%%%|*******|%%%%%%%|*******|%%%%%%%|*******|%%%%%%%|*******| D
		   -----------------------------------------------------------------   
		E  |*******|%%%%%%%|*******|%%%%%%%|*******|%%%%%%%|*******|%%%%%%%| E
		   -----------------------------------------------------------------   
		F  |%%%%%%%|*******|%%%%%%%|*******|%%%%%%%|*******|%%%%%%%|*******| F
		   -----------------------------------------------------------------   
		G  |*******|%%%%%%%|*******|%%%%%%%|*******|%%%%%%%|*******|%%%%%%%| G
		   -----------------------------------------------------------------   
		H  |%%%%%%%|*******|%%%%%%%|*******|%%%%%%%|*******|%%%%%%%|*******| H
		   -----------------------------------------------------------------   
		      0       1       2       3       4       5       6       7   




		      0       1       2       3       4       5       6       7   
		   -----------------------------------------------------------------   
		A  |*******|%%%%%%%|*******|%%%%%%%|*******|%%%%%%%|*******|%%%%%%%| A
		   -----------------------------------------------------------------   
		B  |%%%%%%%|*******|%%%%%%%|*******|%%%%%%%|*******|%%%%%%%|*******| B
		   -----------------------------------------------------------------   
		C  |*******|%%%%%%%|*******|%%%%%%%|*******|%%%%%%%|*******|%%%%%%%| C
		   -----------------------------------------------------------------   
		D  |%%%%%%%|*******|%%%%%%%|*******|%%%%%%%|*******|%%%%%%%|*******| D
		   -----------------------------------------------------------------   
		E  |*******|%%%%%%%|*******|%%%%%%%|*******|%%%%%%%|*******|%%%%%%%| E
		   -----------------------------------------------------------------   
		F  |%%%%%%%|*******|%%%%%%%|*******|%%%%%%%|*******|%%%%%%%|*******| F
		   -----------------------------------------------------------------   
		G  |*******|%%%%%%%|*******|%%%%%%%|*******|%%%%%%%|*******|%%%%%%%| G
		   -----------------------------------------------------------------   
		H  |%%%%%%%|*******|%%%%%%%|*******|%%%%%%%|*******|%%%%%%%|*******| H
		   -----------------------------------------------------------------   
		      0       1       2       3       4       5       6       7