Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2019
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.41 KB | None | 0 0
  1. //******************************************************************
  2. // Chessboard program
  3. // This program prints a chessboard pattern that is built up from
  4. // basic strings of white and black characters.
  5. //******************************************************************
  6. #include <iostream>
  7. #include <string>
  8. using namespace std;
  9.  
  10. const string BLACK = "%%%%%%%%";  // Define a line of a black square
  11. const string WHITE = "        ";  // Define a line of a white square
  12.  
  13. int main ()
  14. {
  15.   string whiteRow;          // A row beginning with a white square
  16.   string blackRow;          // A row beginning with a black square
  17.  
  18.   // Create a white-black row by concatenating the basic strings
  19.   whiteRow = WHITE + BLACK + WHITE + BLACK +
  20.                  WHITE + BLACK + WHITE + BLACK;
  21.   // Create a black-white row by concatenating the basic strings
  22.   blackRow = BLACK + WHITE + BLACK + WHITE +
  23.                  BLACK + WHITE + BLACK + WHITE;
  24.  
  25.   // Print five white-black rows
  26.   cout << whiteRow << endl;
  27.   cout << whiteRow << endl;
  28.   cout << whiteRow << endl;
  29.   cout << whiteRow << endl;
  30.   cout << whiteRow << endl;
  31.  
  32.   // Print five black-white rows
  33.   cout << blackRow << endl;
  34.   cout << blackRow << endl;
  35.   cout << blackRow << endl;
  36.   cout << blackRow << endl;
  37.   cout << blackRow << endl;
  38.  
  39.   // Print five white-black rows
  40.   cout << whiteRow << endl;
  41.   cout << whiteRow << endl;
  42.   cout << whiteRow << endl;
  43.   cout << whiteRow << endl;
  44.   cout << whiteRow << endl;
  45.   // Print five black-white rows
  46.   cout << blackRow << endl;
  47.   cout << blackRow << endl;
  48.   cout << blackRow << endl;
  49.   cout << blackRow << endl;
  50.   cout << blackRow << endl;
  51.   // Print five white-black rows
  52.   cout << whiteRow << endl;
  53.   cout << whiteRow << endl;
  54.   cout << whiteRow << endl;
  55.   cout << whiteRow << endl;
  56.   cout << whiteRow << endl;
  57.  
  58.   // Print five black-white rows
  59.   cout << blackRow << endl;
  60.   cout << blackRow << endl;
  61.   cout << blackRow << endl;
  62.   cout << blackRow << endl;
  63.   cout << blackRow << endl;
  64.  
  65.   // Print five white-black rows
  66.   cout << whiteRow << endl;
  67.   cout << whiteRow << endl;
  68.   cout << whiteRow << endl;
  69.   cout << whiteRow << endl;
  70.   cout << whiteRow << endl;
  71.  
  72.   // Print five black-white rows
  73.   cout << blackRow << endl;
  74.   cout << blackRow << endl;
  75.   cout << blackRow << endl;
  76.   cout << blackRow << endl;
  77.   cout << blackRow << endl;
  78.  
  79. //  system("PAUSE"); //if using Dev C++
  80.   return 0;
  81. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement