The problem was to write a program which allocates the integers 1-8 to the squares in the figure above, subject to the restrictions that no two adjacent squares contain consecutive integers. By adjacent we mean vertically, horizontally, or diagonally. Say we label the eight "boxes" as follows:

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter3: Input/output
Section: Chapter Questions
Problem 4PE: 4. During each summer, John and Jessica grow vegetables in their backyard and buy seeds and...
icon
Related questions
Question
9. One of the programs that you wrote this semester was "Eight numbers in a cross."
The problem was to write a program which allocates the integers 1-8 to the squares in the figure above,
subject to the restrictions that no two adjacent squares contain consecutive integers.
By adjacent we mean vertically, horizontally, or diagonally.
Say we label the eight "boxes" as follows:
1
4
2
5
3
6
In the above diagram, the numbers 0-7 in the boxes are not the values in the boxes but the “names" of the
boxes.
In the program we used a "helper array:
int a[8][5]={
{-1},
{
},
{
},
{
},
{
},
{
},
{
},
{
}
};
Question:
Given the labeling of the boxes of the cross as above, fill in the values in the "helper array" a.
Transcribed Image Text:9. One of the programs that you wrote this semester was "Eight numbers in a cross." The problem was to write a program which allocates the integers 1-8 to the squares in the figure above, subject to the restrictions that no two adjacent squares contain consecutive integers. By adjacent we mean vertically, horizontally, or diagonally. Say we label the eight "boxes" as follows: 1 4 2 5 3 6 In the above diagram, the numbers 0-7 in the boxes are not the values in the boxes but the “names" of the boxes. In the program we used a "helper array: int a[8][5]={ {-1}, { }, { }, { }, { }, { }, { }, { } }; Question: Given the labeling of the boxes of the cross as above, fill in the values in the "helper array" a.
Expert Solution
steps

Step by step

Solved in 2 steps with 3 images

Blurred answer
Knowledge Booster
Random Class and its operations
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning