|  | Christmas trees |  | |
| | | Bert |  |
| Posted: Sun Jun 22, 2008 12:13 am Post subject: Christmas trees |  |
How can my response to this problem be better? The pot doesn't work that well when you enter 25, 21, 17 and some others.
The problem:
CHRISTMAS TREES
The grade 5 class at the local primary school wants some Christmas tree outlines to colour in for the break-up session. You have to write a program which will ask for an odd number representing the size of the tree, rejecting negative quantities and numbers greater than sixty, and then draw a tree centrally placed on the printer page similar to the one below. * * * * * * * * * * * * * Base Line---> *************** * * ******* * * * * ***
The base line of the tree will be made of as many asterisks (*) as the number that was input, and lines above it will have each of the outline asterisks move in one space, until the single * appears at the top.
The pot in which the tree rests should be scaled to suit the tree size.
Download MY source code from:
Click on treetest |
| |
| | | Ben Bacarisse |  |
| Posted: Sun Jun 22, 2008 12:13 am Post subject: Re: Christmas trees |  |
Bert <albert.xtheunknown0@gmail.com> writes:
| Quote: | How can my response to this problem be better? The pot doesn't work that well when you enter 25, 21, 17 and some others.
The problem:
CHRISTMAS TREES
|
Are you going to go through all 33 problem from the Australian Computer Competition Junior Sample Questions? This is the first and the three-move knight's reach is the last. Have these been assigned as your homework?
-- Ben. |
| |
| | | Barry Schwarz |  |
| Posted: Sun Jun 22, 2008 12:13 am Post subject: Re: Christmas trees |  |
On Sat, 21 Jun 2008 17:13:34 -0700 (PDT), Bert <albert.xtheunknown0@gmail.com> wrote:
| Quote: | How can my response to this problem be better? The pot doesn't work that well when you enter 25, 21, 17 and some others.
snip problem description |
Better than what? You didn't show what your response looks like. If you haven't created one yet, then any working response you create would be better.
Remove del for email |
| |
| | | Bert |  |
| Posted: Sun Jun 22, 2008 1:59 am Post subject: Re: Christmas trees |  |
| |
| | | Bert |  |
| Posted: Sun Jun 22, 2008 2:04 am Post subject: Re: Christmas trees |  |
On Jun 22, 10:32 am, Ben Bacarisse <ben.use...@bsb.me.uk> wrote:
| Quote: | Bert <albert.xtheunkno...@gmail.com> writes: How can my response to this problem be better? The pot doesn't work that well when you enter 25, 21, 17 and some others.
The problem:
CHRISTMAS TREES
Are you going to go through all 33 problem from the Australian Computer Competition Junior Sample Questions? This is the first and the three-move knight's reach is the last. Have these been assigned as your homework?
-- Ben.
|
Why not? I'll be like the only one who'll maybe get one problem done in the two hours in my school cos none of the electives ever focus on programming. I'm largely self-taught with 5 or 6 programming books in my shelf and once in year asking one of my dad's friends for help or posting on Google Groups. I have no tutor, see? |
| |
| | | redraiment |  |
| Posted: Mon Jun 23, 2008 8:30 am Post subject: Re: Christmas trees |  |
| |  | |
On Jun 22, 8:13 am, Bert <albert.xtheunkno...@gmail.com> wrote:
| Quote: | How can my response to this problem be better? The pot doesn't work that well when you enter 25, 21, 17 and some others.
The problem:
CHRISTMAS TREES
The grade 5 class at the local primary school wants some Christmas tree outlines to colour in for the break-up session. You have to write a program which will ask for an odd number representing the size of the tree, rejecting negative quantities and numbers greater than sixty, and then draw a tree centrally placed on the printer page similar to the one below. * * * * * * * * * * * * * Base Line---> *************** * * ******* * * * * ***
The base line of the tree will be made of as many asterisks (*) as the number that was input, and lines above it will have each of the outline asterisks move in one space, until the single * appears at the top.
The pot in which the tree rests should be scaled to suit the tree size.
Download MY source code from:
Click on treetest
|
Where's your source code? I can't see the link... |
| |
| | | Richard Heathfield |  |
| Posted: Tue Jun 24, 2008 7:11 am Post subject: Re: Christmas trees |  |
| |  | |
Bert said:
| Quote: | On Jun 23, 6:30 pm, redraiment <redraim...@gmail.com> wrote: On Jun 22, 8:13 am, Bert <albert.xtheunkno...@gmail.com> wrote:
snip
Download MY source code from:
Click on treetest
Where's your source code? I can't see the link...
I posted it a little later. Find my other posts in this thread.
|
I did. I don't see any source, though.
If you mean the Web URL you posted, forget it. Very few will bother to follow that link, at least until they know you a bit better. If you want Usenet people to check out your source, reduce it to the smallest possible program that still demonstrates the problem you're suffering, and post it in a Usenet article together with an explanation of the problem and any data required for running it.
No, I'm not telling you what to do. I'm suggesting a course of action that will probably work for you. Obviously you do what you like, but you might want to think about why some people here are a bit wary of visiting apparently arbitrary URLs.
-- Richard Heathfield <http://www.cpax.org.uk> Email: -http://www. +rjh@ Google users: <http://www.cpax.org.uk/prg/writings/googly.php> "Usenet is a strange place" - dmr 29 July 1999 |
| |
| | | Bert |  |
| Posted: Tue Jun 24, 2008 7:46 am Post subject: Re: Christmas trees |  |
| |  | |
On Jun 23, 6:30 pm, redraiment <redraim...@gmail.com> wrote:
| Quote: | On Jun 22, 8:13 am, Bert <albert.xtheunkno...@gmail.com> wrote:
How can my response to this problem be better? The pot doesn't work that well when you enter 25, 21, 17 and some others.
The problem:
CHRISTMAS TREES
The grade 5 class at the local primary school wants some Christmas tree outlines to colour in for the break-up session. You have to write a program which will ask for an odd number representing the size of the tree, rejecting negative quantities and numbers greater than sixty, and then draw a tree centrally placed on the printer page similar to the one below. * * * * * * * * * * * * * Base Line---> *************** * * ******* * * * * ***
The base line of the tree will be made of as many asterisks (*) as the number that was input, and lines above it will have each of the outline asterisks move in one space, until the single * appears at the top.
The pot in which the tree rests should be scaled to suit the tree size.
Download MY source code from:
Click on treetest
Where's your source code? I can't see the link...
|
I posted it a little later. Find my other posts in this thread. |
| |
| | | pete |  |
| Posted: Tue Jun 24, 2008 3:19 pm Post subject: Re: Christmas trees |  |
| |  | |
Bert wrote:
| Quote: | How can my response to this problem be better?
|
Leave tab characters out of your source code.
| Quote: | The pot doesn't work that well when you enter 25, 21, 17 and some others.
The problem:
CHRISTMAS TREES
The grade 5 class at the local primary school wants some Christmas tree outlines to colour in for the break-up session. You have to write a program which will ask for an odd number representing the size of the tree, rejecting negative quantities and numbers greater than sixty, and then draw a tree centrally placed on the printer page similar to the one below. * * * * * * * * * * * * * Base Line---> *************** * * ******* * * * * ***
The base line of the tree will be made of as many asterisks (*) as the number that was input, and lines above it will have each of the outline asterisks move in one space, until the single * appears at the top.
The pot in which the tree rests should be scaled to suit the tree size.
Download MY source code from:
Click on treetest
|
#include <stdio.h>
int main(void) { int ts, x, i, j, y, a, z;
printf("Enter the size of the tree: "); fflush(stdout); if (scanf("%d", &ts) != 1 || ts % 2 == 0) { puts("Trees have to be an odd size. An odd number..."); return 0; } if (ts < 0) { puts("Trees can't have a negative size..."); return 0; } if (ts > 60) { puts("Trees can't be bigger than 60. Not here anywway..."); return 0; } x = ts / 2; for (i = 0; x > i; ++i) { if (i == 0) { for (j = 0; x > j; ++j) { putchar(' '); } puts("*"); } else { a = x - i; for (j = 0; a > j; ++j) { putchar(' '); } putchar('*'); a = i * 2 - 1; for (j = 0; a > j; ++j) { putchar(' '); } puts("*"); } } for (i = 0; ts > i; ++i) { putchar('*'); } putchar('\n'); for (i = 0; 2 > i; ++i) { for (j = 0; x > j; ++j) { putchar(' '); } puts("*"); } if (8 > ts) { return 0; } a = (ts - x) / 2; for (i = 0; a > i; ++i) { putchar(' '); } x -= x % 2; a = x + 1; for (i = 0; a > i; ++i) { putchar('*'); } putchar('\n'); y = (ts - x) / 2; for (i = 0; y > i ; ++i) { putchar(' '); } putchar('*'); a = x - 1; for (j = 0; a > j; ++j) { putchar(' '); } puts("*"); z = ts / 4 - 2; for (i = 0; z > i; ++i) { a = 1 + y + i; for (j = 0; a > j; ++j) { putchar(' '); } putchar('*'); a = x - 2 * i - 3; for (j = 0; a > j; ++j) { putchar(' '); } puts("*"); } a = (ts - 3) / 2; for(i = 0; a > i; ++i) { putchar(' '); } puts("***"); return 0; }
-- pete |
| |
|
|