Wrox Programmer Forums
|
C++ Programming General discussions for the C++ language. For questions specific to Microsoft's Visual C++ variant, see the Visual C++ forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C++ Programming section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old January 27th, 2007, 09:13 AM
Registered User
 
Join Date: May 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default sequences

hey was jus wondering if anyone knew how to create the following sequences as below:

1)

54321
 4321
  321
   21
    1

2)

123
321

and also how to reverse an int.

Thank You,
Cheers,
Arun[/i]

Reply With Quote
  #2 (permalink)  
Old January 28th, 2007, 09:44 PM
Registered User
 
Join Date: Jan 2007
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

what u need is the data structure algorithm, image u store each element into a single room, then rotate the room to left, just like left shift it. Ex: room[0] = 1, room[1] = 2, room[2] = 3, then output it as room[2]room[1]room[0] = 321.
There may be better solutions, i just suggest one of it.

Reply With Quote
  #3 (permalink)  
Old January 29th, 2007, 08:27 AM
Registered User
 
Join Date: Jan 2007
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

for(int i=1; i<6; i++){
    for(int j=6-i; j>0; j--)
        printf("%d", j);
    printf("\n");
}

Best Regards,
Francesco Andrio
Reply With Quote





Similar Threads
Thread Thread Starter Forum Replies Last Post
Does MS-Access 2003 support Sequences ramuis78 Access 0 July 5th, 2006 10:51 AM
creating finate sequences ajm235 C++ Programming 13 October 6th, 2004 03:30 PM
Escape sequences for HTML olambe BOOK: ASP.NET Website Programming Problem-Design-Solution 2 July 28th, 2004 08:54 AM
record sequences isheikh SQL Server 2000 2 April 9th, 2004 01:16 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.