Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > C# and C > C++ and Visual C++ > Visual C++
Password Reminder
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
Visual C++ Questions specific to Microsoft's Visual C++. For questions not specific to this Microsoft version, use the C++ Programming forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Visual C++ section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old January 3rd, 2007, 03:57 PM
Registered User
Join Date: Jan 2007
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default how to sort an array ascending, help

Hy , this is my code, i am a beginner, i just want to make a program that will request an int array[10] and will rearange it asecenetly,
the problem seems easy to solve but is not.

#include <iostream>
using namespace std;

void v(int q[],int fc[]);

void main() {

    int i[10];
    int h[10];
    for (int a= 0;a<10;a++){
        cout<<"\n\t h["<<a<<"] = ";
        cin>> h[a];
        cout << "\n\t i["<<a<<"] ="<<i[a];


void v(int ui[],int ui2[]) {

    int r;
    int s(0);
    for(int i=0;i<10;i++) {
        if(r<ui[i]) {

    for(int y=9;y>-1;y--) {
        for (i=0;i<10;i++) {
            if((ui2[y]<ui[i]) && (ui2[y]<r)) { // *
                ui2[y] = ui[i]; s++;
            r= ui2[y];cout<<"\n\t r="<<r; // **

* : the problem here : cannot see why the if statement functions in that manner, just compile it and see

** i just wrote taht to see at each loop ending if the r is well implemented , it is not, it should have been the last biggest number smaller than the preious biggest one

Reply With Quote
  #2 (permalink)  
Old March 26th, 2007, 05:19 PM
Registered User
Join Date: Mar 2007
Location: Venice, FL, USA.
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts

Try using either brute force (search elements one at a time looking for largest then filling an array) or quicksort (standard C++).
Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Listing dates ascending lgschulz VB.NET 2002/2003 Basics 1 December 19th, 2006 09:22 AM
parseInt - sort ascending crmpicco Javascript How-To 3 July 5th, 2005 09:13 AM
sort array of strings error lanita BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 1 December 14th, 2004 08:52 PM
Sort ascending and descending bertcox XSLT 1 May 17th, 2004 05:36 AM
array list sort linfakngiau BOOK: Beginning Java 2 2 October 19th, 2003 12:50 PM

All times are GMT -4. The time now is 01:28 AM.

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