codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:
Search Forums:
  Interview Problem 2  iffy38 at 12:37 on Thursday, September 29, 2005
 

Hi there i have this problem the question is:

write an algorithm to sort an array of integers.

now i have had a go at this and my solution works shown below:

list<int> number;
list<int>::iterator i;
int j =0;
int Input[] = {1,3,5,7,3,9,11,54,32};


for (j =0; j < 9; j++) {
number.push_back(Input[j]);

}

cout<<"the contents are "<<endl;
i = number.begin();

while (i != number.end()) {
cout<< *i <<" ";
i++;
}

cout<<endl;
number.sort();

cout<<"the sorted contents are "<<endl;
i = number.begin();

while (i != number.end()) {
cout<< *i <<" ";
i++;
}
cout<<endl;

Now the problem is with this implemenation i am just sorting an array of stored numbers but what if i wanted the user to enter numbers and pass this into an array then put the array into a list and sort it. I tried to do this but i just couldn't get the hang of the EOF operator and coudln't stop the input using that.

If anyone can help me with user entry using the EOF operator into the array then putting this array into the stl list i will be most gratefull.

Thanks
Iffy.










CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums








Recent Forum Threads
•  Why Use Method?
•  Re: Help with filesystem object & displaying in a table
•  Re: Genetic Algorithm Help
•  Re: How to make an investment calculator
•  Re: line breaks in GUI
•  Re: Graph in Gui...
•  Graph in Gui...
•  Re: Counting zero values in a string
•  Re: Help!


Recent Articles
Multiple submit buttons with form validation
Understanding Hibernate ORM for Java/J2EE
HTTP screen-scraping and caching
a javascript calculator
A simple way to JTable
Java Native Interface (JNI)
Parsing Dynamic Layouts
MagicGrid
Caching With ASP.Net
Creating CSS Buttons


Site Survey
Help us serve you better. Take a five minute survey. Click here!

© Copyright codetoad.com 2001-2005