NEED SOME HELP GUYS.... :(

J

Joe Black

Just to inform you guys that i have only like 2 weeks that i took my
first classes in c++, and my proffesor now is asking me to solve this
problem:
/// Using a function create a Win32 Console Application which outputs
asterisks (*)on the screen displaying your name like a matrix screen.
it has to be in a top down-design style. PLS HELP THIS AMATEUR
STUDENT. *_*
if you can help me just send the source code... even that i cant do
that i can fidure out that it should be simple.
thank you Joe
 
J

JKop

Joe Black posted:
Just to inform you guys that i have only like 2 weeks that i took my
first classes in c++, and my proffesor now is asking me to solve this
problem:
/// Using a function create a Win32 Console Application which outputs
asterisks (*)on the screen displaying your name like a matrix screen.
it has to be in a top down-design style. PLS HELP THIS AMATEUR
STUDENT. *_*
if you can help me just send the source code... even that i cant do
that i can fidure out that it should be simple.
thank you Joe

Step 1:

Open Notepad, pick a monospace font and design your name.


Step 2:

Use standard output to output the string.



Google for "cout".


-JKop
 
M

Mike Wahler

Joe Black said:
Just to inform you guys that i have only like 2 weeks that i took my
first classes in c++, and my proffesor now is asking me to solve this
problem:
/// Using a function create a Win32 Console Application which outputs
asterisks (*)on the screen displaying your name like a matrix screen.
it has to be in a top down-design style.

That seems to me a reasonable assignment after two weeks of
classes.
PLS HELP THIS AMATEUR
STUDENT. *_*

Of course we'll help you. What we will not do is do it for you.
Show us the code of your best attempt, and ask specific questions.
if you can help me just send the source code...

Sending you the code would help you not at all (it might help
you pass your course, if you didn't get caught cheating, that is).
It certainly would not help you learn. "Give a man a fish", and
all that.
even that i cant do

Did you even try? If so, show us the code. If not, try.
that i can fidure out that it should be simple.

It is relatively simple.

Hints: Don't try to do it all at once. Do a little at a time,
testing as you go. Don't add more until what you have works
correctly. E.g. first write something that outputs a series
of asterisks (any number of them). Then perhaps something
which outputs a series of asterisks with interspersed spaces
(again, use any number of asterisks or spaces, just to get a
feel for things.) Then try to do the output on more than one
line. Then do multiple lines of differing lengths. Then
multiple lines with differing numbers of asterisks, then with
the spaces at differnent locations on a line, then differing
numbers of spaces, etc. etc.

Walk before you run. Here's a simple skeleton program to
get you started:

#include <iostream>

void ast(unsigned int how_many)
{
for(unsigned int i = 0; i < how_many; ++i)
std::cout << '*';

std::cout << '\n';
}

int main()
{
ast(42);
ast(25);
return 0;
}

-Mike
 
M

Mike Wahler

JKop said:
Joe Black posted:


Step 1:

Open Notepad, pick a monospace font and design your name.


Step 2:

Use standard output to output the string.

I seriously doubt that is a solution which would be
accepted by the instructor. I'm fairly certain he's
looking for loops. But of course one should verify
that before proceeding.


-Mike
 
J

John Harrison

Joe Black said:
Just to inform you guys that i have only like 2 weeks that i took my
first classes in c++, and my proffesor now is asking me to solve this
problem:
/// Using a function create a Win32 Console Application which outputs
asterisks (*)on the screen displaying your name like a matrix screen.
it has to be in a top down-design style. PLS HELP THIS AMATEUR
STUDENT. *_*
if you can help me just send the source code... even that i cant do
that i can fidure out that it should be simple.
thank you Joe

Normally I don't help with homework whenthe poster has made no attempt
themselves. But this is so easy that I figure its not going to do you any
harm to give you the solution.

#include <iostream>

int main()
{
std::cout << "***** *** *****\n";
std::cout << " * * * *\n";
std::cout << " * * * ****\n";
std::cout << " * * * *\n";
std::cout << "** *** *****\n";
}

(best viewed using a fixed width font).

Good luck on the rest of your course, it is going to get a lot more
difficult than this.

john
 
O

osmium

Joe Black said:
Just to inform you guys that i have only like 2 weeks that i took my
first classes in c++, and my proffesor now is asking me to solve this
problem:
/// Using a function create a Win32 Console Application which outputs
asterisks (*)on the screen displaying your name like a matrix screen.
it has to be in a top down-design style. PLS HELP THIS AMATEUR
STUDENT. *_*
if you can help me just send the source code... even that i cant do
that i can fidure out that it should be simple.
thank you Joe

I wouldn't classify any of the help or solutions I have seen posted as
meeting the top down stipulation. I think he wants something with more
potential to be an actual program that has the potential,at least, to be
used by someone who wasn't named Joe. It is possible, of course, that there
are responses I haven't seen.

Early dot matrix printers used a 5 x7 matrix. I doubt very much if there is
any automated way to produce the 52 latin letters. But you could write a
program that handles Joe so far, and has the potential for other names as
well. Get a piece of graph paper and start doodling in a 5 x 7 array. You
will see several strokes that are widely used. Five asterisks in a
horizontal row, for example, on the E, F, L, Z, .... There are also short
bars, *perhaps* rounded corners, slanted bars, (K and R) And so on. A
switch statement *might be* useful, I don't really know, I haven't thought
about it that much.
 
A

Alf P. Steinbach

* osmium:
Early dot matrix printers used a 5 x7 matrix. I doubt very much if there is
any automated way to produce the 52 latin letters.

Aah, you forgot: to Peek the ROM!

Oops, that was Basic, 1970's (I used that technique to present somewhat
derogatory comments about the principal of our high school, it was very
clever because I accessed the lowercase letters in spite of the keyboard
only producing uppercase).

But I'm fairly certain that 5*7 character data must be on the net somewhere,
if only for ASCII art.

But you could write a
program that handles Joe so far, and has the potential for other names as
well. Get a piece of graph paper and start doodling in a 5 x 7 array. You
will see several strokes that are widely used. Five asterisks in a
horizontal row, for example, on the E, F, L, Z, .... There are also short
bars, *perhaps* rounded corners, slanted bars, (K and R) And so on. A
switch statement *might be* useful, I don't really know, I haven't thought
about it that much.

Arrays.
 
M

Moonlit

Hi,

Joe Black said:
Just to inform you guys that i have only like 2 weeks that i took my
first classes in c++, and my proffesor now is asking me to solve this
problem:
/// Using a function create a Win32 Console Application which outputs
asterisks (*)on the screen displaying your name like a matrix screen.
it has to be in a top down-design style. PLS HELP THIS AMATEUR
STUDENT. *_*
if you can help me just send the source code... even that i cant do
that i can fidure out that it should be simple.
thank you Joe

Hi,

Some pointers and ideas.

Look into
-CreateDIBSection
-TextOut
-CreateFont

etc.

Write something to the bitmap
Then read the bits that make up the bitmap and output a star to the console
if a bit is set..

Look on microsoft MSDN or the compilers help pages for a description of the
various functions.

Well the rest is up to you.

Regards, Ron AF Greve.
 
J

JKop

John Harrison posted:
Normally I don't help with homework whenthe poster has made no attempt
themselves. But this is so easy that I figure its not going to do you
any harm to give you the solution.

#include <iostream>

int main()
{
std::cout << "***** *** *****\n";
std::cout << " * * * *\n";
std::cout << " * * * ****\n";
std::cout << " * * * *\n";
std::cout << "** *** *****\n";
}

(best viewed using a fixed width font).

Good luck on the rest of your course, it is going to get a lot more
difficult than this.

john

Why the multiple calls to cout?

#include <iostream>

int main()

std::cout <<

"***** *** *****\n"
" * * * *\n"
" * * * ****\n"
" * * * *\n"
"** *** *****\n";
}


-JKop
 
P

Pedro Graca

JKop said:
John Harrison posted:

#include <iostream>

int main()

std::cout <<

"***** *** *****\n"
" * * * *\n"
" * * * ****\n"
" * * * *\n"
"** *** *****\n";
}

[newbie here]

Shouldn't you both

std::cout << std::endl;

to flush the 'cout' stream?

Or the final '\n' does it on its own?
Or it really isn't needed? (I think I read somewhere it *IS* needed)
 
R

red floyd

Moonlit said:
Hi,




Hi,

Some pointers and ideas.

Look into
-CreateDIBSection
-TextOut
-CreateFont

etc.

Write something to the bitmap
Then read the bits that make up the bitmap and output a star to the console
if a bit is set..

Look on microsoft MSDN or the compilers help pages for a description of the
various functions.

Well the rest is up to you.

Regards, Ron AF Greve.

Your answer is *WRONG*. He said "Console App". And the Win32 API is OT
in this forum.
 
M

Mike Wahler

Pedro Graca said:
JKop said:
John Harrison posted:
std::cout <<

"***** *** *****\n"
" * * * *\n"
" * * * ****\n"
" * * * *\n"
"** *** *****\n";
}

[newbie here]

Shouldn't you both

std::cout << std::endl;

to flush the 'cout' stream?

Only if you need to ensure previous output appears
before subsequent output. Not applicable here, but
also note that performing input with 'cin' after
output with 'cout' will cause 'cout' to be flushed
before the input.
Or the final '\n' does it on its own?

Yes, since the scope (of main()) will be exited, invoking
'cout's destructor, which will cause a flush.
Or it really isn't needed? (I think I read somewhere it *IS* needed)

See above.

-Mike
 
T

Thomas Matthews

Joe said:
Just to inform you guys that i have only like 2 weeks that i took my
first classes in c++, and my proffesor now is asking me to solve this
problem:
/// Using a function create a Win32 Console Application which outputs
asterisks (*)on the screen displaying your name like a matrix screen.
it has to be in a top down-design style. PLS HELP THIS AMATEUR
STUDENT. *_*
if you can help me just send the source code... even that i cant do
that i can fidure out that it should be simple.
thank you Joe

This will be for 5 x 7 fonts, but can be applied to
3 x 5 or any other size.

The easiest method is to have a 5 x 7 matrix (array or vector of
vectors) to contain the character pattern:
0 1 2 3 4
0 * * * * *
1 *
2 *
3 *
4 *
5 *
6 *

Let us call each one a cell. If you use constant C style strings,
you data structure would look like:
char t_cell[CELL_HEIGHT][CELL_WIDTH + 1];
The "+1" is to account for the terminating null character.

Let us define a font as a collection, or aggregate of cells.
Generally, there is one cell for each printable character in
the font. A simple method is to make this an array, which
would be a 3 dimensional array:
char font[NUM_OF_CHARS][CELL_HEIGHT][CELL_WIDTH + 1];

Note: I suggested arrays because the font is composed of
constant data. This method requires no extra effort to copy
the data into a dynamic structure such as a vector, list
or map.

To print out a row of characters, use the expression:
font[character - start_char][row_index];
where "character" is the current character being processed
"start_char" is the first character in the font.

So the loop is to print each row of the font for each character:
for each row do:
print font['T' - 'A'][row]
print inter-character-spacing
print font['O' - 'A'][row]
print inter-character-spacing
print font['M' - 'A'][row]
print newline.
end-for

This is the basic algorithm. Further optimizations and
data content are left for the reader.


--
Thomas Matthews

C++ newsgroup welcome message:
http://www.slack.net/~shiva/welcome.txt
C++ Faq: http://www.parashift.com/c++-faq-lite
C Faq: http://www.eskimo.com/~scs/c-faq/top.html
alt.comp.lang.learn.c-c++ faq:
http://www.comeaucomputing.com/learn/faq/
Other sites:
http://www.josuttis.com -- C++ STL Library book
http://www.sgi.com/tech/stl -- Standard Template Library
 
P

Pedro Graca

Mike said:
[edited]
Or [std::cout << std::endl; at the end of main()] really isn't
needed? (I think I read somewhere it *IS* needed)

I must have misinterpreted what I read.

[edited]
[It isn't needed], since the scope (of main()) will be exited,
invoking 'cout's destructor, which will cause a flush.

Ah! :)

Thank you for your explanations Mike, I really appreciate it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,898
Latest member
BlairH7607

Latest Threads

Top