help

S

squeek

i am in a C++ programing class in college (i hate computers because i
learn with my hands and can't tear a computer apart to see how it
works) and i don't know what i am doing with this class i hate it we
are currently working with arrays, and i need help writing a program
that sorts intigers from smallest to to the biggest. thanks in advance
 
J

Jaspreet

squeek said:
i am in a C++ programing class in college (i hate computers because i
learn with my hands and can't tear a computer apart to see how it
works) and i don't know what i am doing with this class i hate it we
are currently working with arrays, and i need help writing a program
that sorts intigers from smallest to to the biggest. thanks in advance

Lets leave the hatred aside for a moment and try on our own to solve
the problem at hand.

Say if I give you 5 different integers viz 23, 11, 2, 56, 5 how would
you go about arranging them in ascending (smallest to bigger) order ?

You would first start off with 23 and compare it others and bring 11
forward in place of 23 and then 2 forward and so on...So after the 1st
round, you would have :
11, 2, 5, 56, 25....

Next start off with 11 and continue...

So continue your rounds and after sometime you may have the array in
correct order.

Note : This is not one of the more efficient techniques for sorting
though. Once you get an idea, someone would try and tell you why it is
not efficient and which is a better option. But then someone might
stand up and say why not start with the most efficient technique
rightaway ? Good question, I dont remember that technique. :(
 
O

osmium

squeek said:
i am in a C++ programing class in college (i hate computers because i
learn with my hands and can't tear a computer apart to see how it
works)

<snip remainder of sentence>

Sadly, if you *were* allowed to take it apart you would learn exactly
nothing about how a computer works. You were probably born too late, should
have been born when men and horses tilled the land for a good honest living
with lots of man sweat and horse sweat.
 
B

benben

squeek said:
i am in a C++ programing class in college (i hate computers because i
learn with my hands and can't tear a computer apart to see how it
works) and i don't know what i am doing with this class i hate it we
are currently working with arrays, and i need help writing a program
that sorts intigers from smallest to to the biggest. thanks in advance

I am finding hard to understand why you choose a course that you hate so
much.

RED PILL
Calm down and take a C++ book and try to develop some interest in it.

BLUE PILL
Just go ahead change your course to whatever you like, or you don't hate.

Now pick your poison.

Regards,
Ben
 
D

Daniel T.

"squeek said:
i am in a C++ programing class in college (i hate computers because i
learn with my hands and can't tear a computer apart to see how it
works) and i don't know what i am doing with this class i hate it we
are currently working with arrays, and i need help writing a program
that sorts intigers from smallest to to the biggest. thanks in advance

#include <iostream>
// whatever includes you need for your code

using namespace std;

void sort_ints( int* array, unsigned size ) {
// your code here
}

int main() {
int a[2] = { 2, 1 };
sort_ints( a, 2 );
assert( a[0] == 1 );
assert( a[1] == 2 );
cout << "Working!\n";
}

Take the above code and paste it into your cpp file. Add code to the
"your code here" spot until it says "Working!". Show us what you have so
far and we'll help you over the next step.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,188
Latest member
Crypto TaxSoftware

Latest Threads

Top