CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 1 of 2 12 LastLast
Results 1 to 15 of 29
  1. #1
    Join Date
    Jul 2003
    Posts
    11

    Printing the array elements in order without sorting????

    Hi all,

    I am trying to print the elements in an array without sorting the array........Can u help me out with some hints...

    Thanks in advance,
    Koti Reddy
    ---------------------------------
    Participation matters always...in "all" ways.

  2. #2
    Join Date
    Nov 2003
    Location
    Belgium
    Posts
    8,150
    How could you print the elements of an array or whatever in order WITHOUT sorting? If you want order, you need sorting.
    Marc Gregoire - NuonSoft (http://www.nuonsoft.com)
    My Blog
    Wallpaper Cycler 3.5.0.97

    Author of Professional C++, 4th Edition by Wiley/Wrox (includes C++17 features)
    ISBN: 978-1-119-42130-6
    [ http://www.facebook.com/professionalcpp ]

  3. #3
    Join Date
    Dec 2003
    Posts
    220
    I think here may be what he meant
    PHP Code:
    1input array[n]; 
    input indicate//indicate is a sign to check if there is nie element left in the array
    2Select order//order is asc or des, and input from user 
    indicate=n;
    3loop array from 0 to n-
    4
    Choose largest//if decreasing order or smallest element if increasing order to print out
    indicate--;
    5Repeat 3// for the second largest
    6Repeat 4// till thereis no element left
    7End loop 
    That s what comes to my mind right now,

    Regards,

    homestead

  4. #4
    Join Date
    May 1999
    Location
    Southern California
    Posts
    12,266
    What do you mean by "array"? If you can use std::vector then that would probably be easier. To print without sorting, simply don't sort.
    Last edited by Sam Hobbs; January 17th, 2004 at 11:39 AM.
    "Signature":
    My web site is Simple Samples.
    C# Corner Editor

  5. #5
    Join Date
    May 1999
    Location
    Southern California
    Posts
    12,266
    Originally posted by Marc G
    How could you print the elements of an array or whatever in order WITHOUT sorting? If you want order, you need sorting.
    Where does Koti say "in order"?
    "Signature":
    My web site is Simple Samples.
    C# Corner Editor

  6. #6
    Join Date
    May 2000
    Location
    KY, USA
    Posts
    18,652
    Originally posted by Sam Hobbs
    Where does Koti say "in order"?
    In the subject...

  7. #7
    Join Date
    May 1999
    Location
    Southern California
    Posts
    12,266
    Originally posted by Andreas Masur
    In the subject...
    Okay, thank you.

    That's why the question should be asked in the question; that is, the complete question should be in the body of the thread, instead of depending on the subject to ask the question. When I read the body of the thread, I did not see (or at least forgot seeing) the "in order" in the subject.

    Whenever the subject is used for a question without also putting the complete question in the body, it usually wastes the time of people (such as us) trying to help, and the only reason it is done is because the person asking doesn't want to spend a few seconds to put the complete question in the body.
    "Signature":
    My web site is Simple Samples.
    C# Corner Editor

  8. #8
    Join Date
    Dec 2003
    Posts
    220
    Originally posted by Sam Hobbs
    Okay, thank you.

    That's why the question should be asked in the question; that is, the complete question should be in the body of the thread, instead of depending on the subject to ask the question. When I read the body of the thread, I did not see (or at least forgot seeing) the "in order" in the subject.

    Whenever the subject is used for a question without also putting the complete question in the body, it usually wastes the time of people (such as us) trying to help, and the only reason it is done is because the person asking doesn't want to spend a few seconds to put the complete question in the body.
    You should be the best lawyer ever in history if you wanted to .
    The reason I wonder much is what you read first before opening the thread ?

    Regards,

    Fiona

  9. #9
    Join Date
    May 1999
    Location
    Southern California
    Posts
    12,266
    I usually open all threads in a CodeGuru forum's page of threads that I intend to look at before I read a thread. I sometimes have more than ten threads "opened" before I read one. I then read them in reverse order, so that the last one opened is the first one I read, since that is the order that I see them in, due to Windows showing the windows in that order. That way, the less recently updated thread is the first from that page that I read.

    Therefore by the time I look at a thread, it might be as much as a half hour later.

    So does that make a difference in your opinion of whether I should be able to remember what the subject is?
    "Signature":
    My web site is Simple Samples.
    C# Corner Editor

  10. #10
    Join Date
    Oct 2002
    Location
    Singapore
    Posts
    3,128
    Just some thought...

    I do agree that beside reading the thread, we should also read the header. However, there are many posters didn't write clear and concise subject header. Worst till, many are like "Help me.." which ain't informative at all. As a result, I am embarrassed to admit that I am some what "conditioned" to ignore the header. Anyway, I believe that it is still very helpful to repeat the question in the thread.

  11. #11
    Join Date
    Dec 2003
    Posts
    99
    Headers help for searching a post of interest for reading.
    The message body should neccesarily contain the entire question.

    How about a strict format for the header ?
    Like <OS><lang>.. . <Question>
    Agreed that this is a C++ group but i have seen a lot of off topics out here.

    Regards

  12. #12
    Join Date
    Dec 2003
    Location
    Russia
    Posts
    23
    What is "in order" ?
    From Min to Max?
    From Max to Min?
    Or any another order?

  13. #13
    Join Date
    Jul 2003
    Posts
    11

    I want Max to Min

    Thanks Debug for ur response...

    I want the order from Max to Min...

    Hope an early reply from u...

    Bye....Koti Reddy
    ---------------------------------
    Participation matters always...in "all" ways.

  14. #14
    Join Date
    Nov 2003
    Location
    Belgium
    Posts
    8,150

    Re: I want Max to Min

    Originally posted by kotireddy
    I want the order from Max to Min...
    You cannot expect order when you do not want to sort.
    Marc Gregoire - NuonSoft (http://www.nuonsoft.com)
    My Blog
    Wallpaper Cycler 3.5.0.97

    Author of Professional C++, 4th Edition by Wiley/Wrox (includes C++17 features)
    ISBN: 978-1-119-42130-6
    [ http://www.facebook.com/professionalcpp ]

  15. #15
    Join Date
    Dec 2003
    Location
    Russia
    Posts
    23
    You can create temporary array,
    copy elements to them,
    sort TEMPORARY array
    print temporary array

    This leave source array unchanged (you do not sort him)
    and print elements in properly order

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured