Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > What does Accelerated C++ exercise 5-5 mean?

Reply
Thread Tools

What does Accelerated C++ exercise 5-5 mean?

 
 
Lambda
Guest
Posts: n/a
 
      04-19-2008
I'm trying to complete all the exercises of Accelerated C++.

I'm not sure what does the exercise 5-5 mean. And how about 5-9?

Thanks
 
Reply With Quote
 
 
 
 
utab
Guest
Posts: n/a
 
      04-19-2008
On Apr 19, 1:34 pm, Lambda <(E-Mail Removed)> wrote:
> I'm trying to complete all the exercises of Accelerated C++.
>
> I'm not sure what does the exercise 5-5 mean. And how about 5-9?
>
> Thanks


That is quite obvious from the text I guess

Let me explain, there are some functions given in chapter 5 to frame
and concatenate some text, this is an extension of those functions.

+ You should write the text centered in the frame. Hint: think about
how can a text can be centered in a frame. And this will also answer
the question if this is possible or not.

+ for 5.9 lets say you keep the words in a vector:

try
TRY
accelerated
ACCELERATED

so the new order should be

accelerated
try
TRY
ACCELERATED

Hint you might use a function "isupper" or "islower" from cctype

HTH,
 
Reply With Quote
 
 
 
 
Lambda
Guest
Posts: n/a
 
      04-20-2008
On Apr 19, 9:14 pm, utab <(E-Mail Removed)> wrote:
> On Apr 19, 1:34 pm, Lambda <(E-Mail Removed)> wrote:
>
> > I'm trying to complete all the exercises of Accelerated C++.

>
> > I'm not sure what does the exercise 5-5 mean. And how about 5-9?

>
> > Thanks

>
> That is quite obvious from the text I guess
>
> Let me explain, there are some functions given in chapter 5 to frame
> and concatenate some text, this is an extension of those functions.
>
> + You should write the text centered in the frame. Hint: think about
> how can a text can be centered in a frame. And this will also answer
> the question if this is possible or not.


Does that mean convert
**************
* this is an *
* example *
* to *
* illustrate *
* framing *
**************
to
**************
* this is an *
* example *
* to *
* illustrate *
* framing *
**************
?
It's always possible except for strings that is too long,
for example, more than 80 characters.

>
> + for 5.9 lets say you keep the words in a vector:
>
> try
> TRY
> accelerated
> ACCELERATED
>
> so the new order should be
>
> accelerated
> try
> TRY
> ACCELERATED
>
> Hint you might use a function "isupper" or "islower" from cctype


The question does not mention the order inside the upper and lower
groups.
I think I just need to separate the input to two groups, right?

I can always get usefull information from this group, thank you utab.

>
> HTH,


 
Reply With Quote
 
utab
Guest
Posts: n/a
 
      04-20-2008
On Apr 20, 4:00 am, Lambda <(E-Mail Removed)> wrote:
> On Apr 19, 9:14 pm, utab <(E-Mail Removed)> wrote:
>
>
>
> > On Apr 19, 1:34 pm, Lambda <(E-Mail Removed)> wrote:

>
> > > I'm trying to complete all the exercises of Accelerated C++.

>
> > > I'm not sure what does the exercise 5-5 mean. And how about 5-9?

>
> > > Thanks

>
> > That is quite obvious from the text I guess

>
> > Let me explain, there are some functions given in chapter 5 to frame
> > and concatenate some text, this is an extension of those functions.

>
> > + You should write the text centered in the frame. Hint: think about
> > how can a text can be centered in a frame. And this will also answer
> > the question if this is possible or not.

>
> Does that mean convert
> **************
> * this is an *
> * example *
> * to *
> * illustrate *
> * framing *
> **************
> to
> **************
> * this is an *
> * example *
> * to *
> * illustrate *
> * framing *
> **************
> ?
> It's always possible except for strings that is too long,
> for example, more than 80 characters.


Ok of course it is limited. a sample output which also gives
indications if the lines could be centered or not:

Info for the lines whether they can be centered or not
Line 1 can be centered
Line 2 can be centered
Line 3 can not be centered
Line 4 can not be centered
Line 5 can not be centered
************************************************** *******************************************
* this is a good this is a good this is a good this is a good this is
a good this is a good *
*
example *
*
to *
*
illustrate *
* centered
framing *
************************************************** *******************************************

Ok you are done. Concerning its feasibility for evenness: there are
things to check there are two '*' chararacters
on the text part of the picture. So a simple algebra should lead to
somewhere right, for instance;

Lets say: the string is "Hello lambda, how are you?" consists of 26
chars.

If this is the longest one in the whole text you are using, then the
adjustment should be done to accommodate this fact, which you solved
above. To adjust a string of length, say 14 chars, what do you do?

How many spacings should be on the right and left?
if you have a string of 15 chars, then is it possible? (This was meant
I guess by the feasibility )
>
>
>
>
>
> > + for 5.9 lets say you keep the words in a vector:

>
> > try
> > TRY
> > accelerated
> > ACCELERATED

>
> > so the new order should be

>
> > accelerated
> > try
> > TRY
> > ACCELERATED

>
> > Hint you might use a function "isupper" or "islower" from cctype

>
> The question does not mention the order inside the upper and lower
> groups.
> I think I just need to separate the input to two groups, right?


That was what I understood but Andrew Koenig also sometimes seems to
post and answer questions on his book, if you are lucky or I am lucky,
he can leave a message

>
> I can always get usefull information from this group, thank you utab.
>
>

You are welcome !
>
> > HTH,


 
Reply With Quote
 
utab
Guest
Posts: n/a
 
      04-20-2008
On Apr 20, 9:40 am, utab <(E-Mail Removed)> wrote:
> On Apr 20, 4:00 am, Lambda <(E-Mail Removed)> wrote:
>
>
>
> > On Apr 19, 9:14 pm, utab <(E-Mail Removed)> wrote:

>
> > > On Apr 19, 1:34 pm, Lambda <(E-Mail Removed)> wrote:

>
> > > > I'm trying to complete all the exercises of Accelerated C++.

>
> > > > I'm not sure what does the exercise 5-5 mean. And how about 5-9?

>
> > > > Thanks

>
> > > That is quite obvious from the text I guess

>
> > > Let me explain, there are some functions given in chapter 5 to frame
> > > and concatenate some text, this is an extension of those functions.

>
> > > + You should write the text centered in the frame. Hint: think about
> > > how can a text can be centered in a frame. And this will also answer
> > > the question if this is possible or not.

>
> > Does that mean convert
> > **************
> > * this is an *
> > * example *
> > * to *
> > * illustrate *
> > * framing *
> > **************
> > to
> > **************
> > * this is an *
> > * example *
> > * to *
> > * illustrate *
> > * framing *
> > **************
> > ?
> > It's always possible except for strings that is too long,
> > for example, more than 80 characters.

>
> Ok of course it is limited. a sample output which also gives
> indications if the lines could be centered or not:
>
> Info for the lines whether they can be centered or not
> Line 1 can be centered
> Line 2 can be centered
> Line 3 can not be centered
> Line 4 can not be centered
> Line 5 can not be centered
> ************************************************** *******************************************
> * this is a good this is a good this is a good this is a good this is
> a good this is a good *
> *
> example *
> *
> to *
> *
> illustrate *
> * centered
> framing *
> ************************************************** *******************************************
>
> Ok you are done. Concerning its feasibility for evenness: there are
> things to check there are two '*' chararacters
> on the text part of the picture. So a simple algebra should lead to
> somewhere right, for instance;
>
> Lets say: the string is "Hello lambda, how are you?" consists of 26
> chars.
>
> If this is the longest one in the whole text you are using, then the
> adjustment should be done to accommodate this fact, which you solved
> above. To adjust a string of length, say 14 chars, what do you do?
>
> How many spacings should be on the right and left?
> if you have a string of 15 chars, then is it possible? (This was meant
> I guess by the feasibility )
>
>
>
>
>
> > > + for 5.9 lets say you keep the words in a vector:

>
> > > try
> > > TRY
> > > accelerated
> > > ACCELERATED

>
> > > so the new order should be

>
> > > accelerated
> > > try
> > > TRY
> > > ACCELERATED

>
> > > Hint you might use a function "isupper" or "islower" from cctype

>
> > The question does not mention the order inside the upper and lower
> > groups.
> > I think I just need to separate the input to two groups, right?

>
> That was what I understood but Andrew Koenig also sometimes seems to
> post and answer questions on his book, if you are lucky or I am lucky,
> he can leave a message
>
>
>
>
>
> > I can always get usefull information from this group, thank you utab.

>
> You are welcome !
>
> > > HTH,


Sorry for the output it can still be used for relatively long strings.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Accelerated C++ - exercise 0-1 arnuld C++ 10 03-18-2007 06:54 PM
Accelerated C++ exercise 8.8 utab C++ 8 04-16-2006 06:18 PM
an interesting exercise by Accelerated C++ utab C++ 3 02-16-2006 03:50 PM
Accelerated C++ exercise utab C++ 2 02-14-2006 05:19 PM
Accelerated C++: exercise 6-1 Pete C++ 14 01-03-2006 08:34 PM



Advertisments