# help

Discussion in 'C++' started by squeek, Apr 4, 2006.

1. ### squeekGuest

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

squeek, Apr 4, 2006

2. ### JaspreetGuest

squeek wrote:
> 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.

Jaspreet, Apr 4, 2006

3. ### osmiumGuest

"squeek" writes:

>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.

osmium, Apr 4, 2006
4. ### benbenGuest

squeek wrote:
> 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.

Regards,
Ben

benben, Apr 4, 2006
5. ### squeekGuest

no that is to late but the 50's would have been great

squeek, Apr 4, 2006
6. ### Daniel T.Guest

In article <>,
"squeek" <> wrote:

> 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 ) {
}

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