![]() |
diamond asterics problem
i was given 10 asterics problems to do. i've completed all of them except for this one. i've given up. i can only get half of the diagram to print
its supposed to print like this ************* row 1 0 spaces ,13* ******-****** row 2 1 spaces, 12* *****-- -***** row 3 3 spaces, 10* ****----- **** row4 5 spaces, 8* ***------- *** row5 7 spaces ,6* **--------- **row6 9 spaces, 4* * ----------- *row7 11 spaces, 2* **--------- **row8 9 spaces ,4* ***------- ***row9 7 spaces ,6* ****----- ****row10 5 spaces ,8* *****--- *****row11 3 spaces ,10* ****** -******row12 1 spaces ,12* *************row13 0 spaces ,13* so far i have :
for(int rows = -6; rows <=6; rows++)but this only pritns half the *'s if anyone can help me do the other half it will be greatly appreciated. i can only use printf(" ") printf("*") printf("\n") once in the whole block of code. thank you |
Try to come up with a mathematical expression for when a star shoudl be printed or not using x and y variables (Row vs Column)
|
Here is the code...
But remember never giveup, keep trying until u find the solution.. :
#include<stdio.h> |
avinashmalipatil: count your printfs - look at the requirements.
|
Here i have modified the code. If there is any mistake, let me know.
:
#include<stdio.h> |
code tags ftw
|
This is not an entirely straightforward problem because of the similarities between the first and second rows and the penultimate and ultimate rows, and the requirement for a minimum of printf statements.
It will require a tad of thinking beforehand to resolve those impediments. I would recommend dividing the problem horizontally (left, center, and right portions), and then incorporate that into the vertical dimension. Use value transitions as a key to behavior modification. |
Quote:
|
Quote:
|
The code is so small and i dont think code tags r required. U can easily understand the code, its so simple. And there is no reply from Blouro. Is ur ploblem solved?
|
| All times are GMT -5. The time now is 3:01 AM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC