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
Printable View
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
How could you print the elements of an array or whatever in order WITHOUT sorting? If you want order, you need sorting.
I think here may be what he meant
That s what comes to my mind right now,PHP Code:1: input array[n];
input indicate; //indicate is a sign to check if there is nie element left in the array
2: Select order; //order is asc or des, and input from user
indicate=n;
3: loop array from 0 to n-1
4: Choose largest; //if decreasing order or smallest element if increasing order to print out
indicate--;
5: Repeat 3; // for the second largest
6: Repeat 4; // till thereis no element left
7: End loop
Regards,
homestead
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.
Where does Koti say "in order"?Quote:
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.
In the subject... :rolleyes:Quote:
Originally posted by Sam Hobbs
Where does Koti say "in order"?
Okay, thank you.Quote:
Originally posted by Andreas Masur
In the subject... :rolleyes:
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 .Quote:
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.
The reason I wonder much is what you read first before opening the thread ?
Regards,
Fiona
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?
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.
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
What is "in order" ?
From Min to Max?
From Max to Min?
Or any another order?
Thanks Debug for ur response...
I want the order from Max to Min...
Hope an early reply from u...
Bye....Koti Reddy
You cannot expect order when you do not want to sort.Quote:
Originally posted by kotireddy
I want the order from Max to Min...
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