Welcome to Dream.In.Code
Getting C++ Help is Easy!

Join 132,672 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 1,166 people online right now. Registration is fast and FREE... Join Now!




One Value parameter

 
Reply to this topicStart new topic

One Value parameter, picture troubles

Simply
post 10 Jun, 2007 - 03:38 AM
Post #1


New D.I.C Head

*
Joined: 2 Apr, 2007
Posts: 22


My Contributions


I get the get following shape to appear correctly when I input 9

[but it wont work when I enter in 6?

QUOTE


Please see attachment - the first one looks correct with 9 being the size but 6 wont work? mad.gif


Here is my code - whats wrong with it?
p.s I am not yet very C++ literate so please be specific and explain in full terms.

CODE


#include <iostream>
using namespace std;

//void function with one value parameter of type int
void drawFigure (int space, int size)
{//Beginning of void function

for (space = space/2; space > 0; space --)//This corrects the spacing so its all inline
{//Beginning of for loop for spaces
cout << " ";
}//End of for loop for spaces

for (int i = 1; i <= size; i++)//This controlles the lines
{//Beginning of for loop for characers
cout << "*";//This is the character used
}//End of for loop for characters

}//End of void function

int main ( )
{

int size;
int n;

//Input
cout << "What size figue would you like to draw?";
cin >> size;

//For loop that works with the lines, relates to the top half on the tree
for (n = 0; n < size; n = n+2)
{
drawFigure (n, size -n);
cout << endl;
cout << endl;
}

//This is the part that the top half and the bottom half of the tree meet up
n = n-2;

//For loop that workes with the lines, relates to the bottom half of the tree
for ( n = n-2;n >=0; n=n-2)
{
drawFigure (n,size-n);
cout << endl;
cout << endl;
}

system ("pause");

return 0;
}



[Mod Edit] for those who don't want to download a word doc:
the output looks like:

*******
.*****
..***
...*
..***
.*****
*******

or with 6 as:

******
.****
..**
..**
.****
******
[/Edit]


Attached File(s)
Attached File  outputs.doc ( 245.5k ) Number of downloads: 19
User is offlineProfile CardPM

Go to the top of the page

gregoryH
post 10 Jun, 2007 - 04:26 AM
Post #2


D.I.C Regular

Group Icon
Joined: 4 Oct, 2006
Posts: 417



Dream Kudos: 50
My Contributions


QUOTE(Simply @ 10 Jun, 2007 - 04:38 AM) *

I get the get following shape to appear correctly when I input 9

[but it wont work when I enter in 6?

QUOTE


Please see attachment - the first one looks correct with 9 being the size but 6 wont work? mad.gif


Here is my code - whats wrong with it?
p.s I am not yet very C++ literate so please be specific and explain in full terms.



hi simply

My first thoughts are on the choice of algorithm and selection of mid point

Did you try other odd or even values? See if they behave the same way.

The results may help you fix your problem
User is offlineProfile CardPM

Go to the top of the page

Simply
post 10 Jun, 2007 - 05:01 AM
Post #3


New D.I.C Head

*
Joined: 2 Apr, 2007
Posts: 22


My Contributions


QUOTE


Did you try other odd or even values? See if they behave the same way.



The poblem is I have to use 6 as my integer.......?
I have tried other numbers and I still dont get what the problem is?

Help please stupid.gif

This post has been edited by Simply: 10 Jun, 2007 - 05:02 AM
User is offlineProfile CardPM

Go to the top of the page

Reply to this topicStart new topic
Time is now: 11/23/08 06:08AM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month