Wednesday, November 14, 2018

problem 8

Planting Crop
A farmer who wants to follow the companion planting method for crops, it would better when they are implementing in gardening and agriculture is the planting of different crops in proximity for pest control, pollination, providing habitat for beneficial creatures, maximizing use of space, and to otherwise increase crop productivity. Companion planting is a form of polyculture.

In the Companion planting method, the crops are planted in the following pattern. 
For n = 5, the pattern should be as follows, 
XXXXXXXXX 
XX - XXX -XX 
X - X - X -X -X 
XX -XXX - XX 
XXXXXXXXX 
XX - XXX- XX 
X- X- X - X - X 
XX - XXX -XX 
XXXXXXXXX 

Hint: Number of rows = 2*n - 1 

Write a program to print the pattern for the given ‘n’ value. 

Input format:
Input is an integer which corresponds to the n.

Output format:
Refer the sample output.

Sample Intput 1:
5
Sample Output 1:
XXXXXXXXX
XX - XXX -XX
X - X - X -X -X
XX -XXX - XX
XXXXXXXXX
XX - XXX- XX
X- X- X - X - X
XX - XXX -XX
XXXXXXXXX

Sample Input 2:
9
Sample Output 2:
XXXXXXXXXXXXXXXXX
XX-----XXX-----XX
X-X---X-X-X---X-X
X--X-X--X--X-X--X
X---X---X---X---X
X--X-X--X--X-X--X
X-X---X-X-X---X-X
XX-----XXX-----XX
XXXXXXXXXXXXXXXXX
XX-----XXX-----XX
X-X---X-X-X---X-X
X--X-X--X--X-X--X
X---X---X---X---X
X--X-X--X--X-X--X
X-X---X-X-X---X-X
XX-----XXX-----XX
XXXXXXXXXXXXXXXXX

No comments:

 DBMS class materials click here to join the class room  click here  https://www.youtube.com/channel/UC93Sqlk_tv9A9cFv-QjZFAQ