473,378 Members | 1,512 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

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
Jun 27 '08 #1
8 3368
Bert <al*****************@gmail.comwrites:
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.
Jun 27 '08 #2
On Sat, 21 Jun 2008 17:13:34 -0700 (PDT), Bert
<al*****************@gmail.comwrote:
>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
Jun 27 '08 #3
On Jun 22, 10:32 am, Ben Bacarisse <ben.use...@bsb.me.ukwrote:
Bert <albert.xtheunkno...@gmail.comwrites:
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?
Jun 27 '08 #5
On Jun 22, 8:13 am, Bert <albert.xtheunkno...@gmail.comwrote:
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...
Jun 27 '08 #6
On Jun 23, 6:30 pm, redraiment <redraim...@gmail.comwrote:
On Jun 22, 8:13 am, Bert <albert.xtheunkno...@gmail.comwrote:
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.
Jun 27 '08 #7
Bert said:
On Jun 23, 6:30 pm, redraiment <redraim...@gmail.comwrote:
>On Jun 22, 8:13 am, Bert <albert.xtheunkno...@gmail.comwrote:
<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
Jun 27 '08 #8
Bert wrote:
How can my response to this problem be better?
Leave tab characters out of your source code.
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
Jun 27 '08 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: C++ Shark | last post by:
Hi, which stl class is good for creating search trees? I am looking for something flexible, that allows me to search for a required state (of matrices, graphs, etc.) quickly. thanks in...
1
by: barnesc | last post by:
Hi again, Since my linear algebra library appears not to serve any practical need (I found cgkit, and that works better for me), I've gotten bored and went back to one of my other projects:...
3
by: ptrSriram | last post by:
Can someone help me with an algorithm to merge two binary search trees. One method I thought of was to flatten both the trees into sorted lists(inorder traversal),merge those two sorted lists,...
2
by: trusiki | last post by:
I am trying to use C# for my program that deals with manipulation of trees (i.e. finding distance between different nodes, assigning labels to nodes, storing trees, etc.). I know I can probably...
17
Ganon11
by: Ganon11 | last post by:
Hey guys, OK, taking care of this beforehand; I AM a student in a university. This IS part of my homework, and (as a moderator), I'm doing my best to follow the posting guidelines I work so hard...
2
by: parasuram | last post by:
Hi friends ............. this is a question regarding the data structures trees Pleas post it if possible with in 2 days I will thankful if some body could help doing this. Operating...
6
by: rsprawls | last post by:
I found a disk for a b-tree algorithm that I purchased back in 93 or so. I'd hoped to find this, but now I'd like to know how worthwhile are b-trees in today's advancements? This is old C code...
0
by: Now You Know | last post by:
Best Christmas Lights Decoration Sale Installation in Los Angeles 818-386-1022 (These types of Innovative lights will definetly add to your Christmas decor) Here are the tips to use: The most...
0
by: Now You Know | last post by:
Best Christmas Lights Decoration Sale Installation in Los Angeles 818-386-1022 (These types of Innovative lights will definetly add to your Christmas decor) Here are the tips to use: The most...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.