problem sorting

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include <iostream>
using namespace std;

void ExchangeSort(apvector <int> &mylist)
{
     int i, j;
     int temp;   // holding variable
     int numLength = mylist.length( ); 
     for (i=0; i< (numLength -1); i++)    // element to be compared
    {
          for(j = (i+1); j < numLength; j++)   // rest of the elements
         {
                if (mylist[i] < mylist[j])          // descending order
               {
                        temp= num[i];          // swap
                        mylist[i] = mylist[j];
                        mylist[j] = temp;
               }
          }
     }
     return;
}

int main(){

	int myfist[10];
	int mylist[10];

	for(int n=0;n<10;n++){
		cout << "Person " << n+1 << ", please enter how many pancakes you ate here: ";
		cin >> mylist[n];
		myfist[n]=n+1;
	}

	cout << endl;

	int big = mylist[0];
	for(int i=1;i<10;i++){
		if(big<mylist[i]){
			big=mylist[i];
		}
	}

	int small = mylist[0];
	for(int i=1;i<10;i++){
		if(small>mylist[i]){
			small=mylist[i];
		}
	}

	for(int c=0;c<10;c++){
		cout << mylist[c] << endl;
	}

	cout << endl << "biggie is " << big << endl << endl;

	cout << "smallie is " << small << endl << endl;

system("pause");
return 0;}


i have been stuck on this for a couple of weeks.
i dont know much about vectors / pvectors but i copy and pasted the codes for bubble sort i think it was from a website where they explained how to sort.

did i forget something? is there an easier way doing this?

thank you
You aren't even using the sort function...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include <iostream>
using namespace std;



int main(){

	int myfist[10];
	int mylist[10];

	for(int n=0;n<10;n++){
		cout << "Person " << n+1 << ", please enter how many pancakes you ate here: ";
		cin >> mylist[n];
		myfist[n]=n+1;
	}

	cout << endl;

	int big = mylist[0];
	for(int i=1;i<10;i++){
		if(big<mylist[i]){
			big=mylist[i];
		}
	}

	int small = mylist[0];
	for(int i=1;i<10;i++){
		if(small>mylist[i]){
			small=mylist[i];
		}
	}

	for(int c=0;c<10;c++){
		cout << mylist[c] << endl;
	}

	cout << endl << "biggie is " << big << endl << endl;

	cout << "smallie is " << small << endl << endl;

system("pause");
return 0;}


this is my original code :( would do anything to learn where to go from here
i really have been trying, i know i am a noob but i dont get it, i swear, i have been trying to, but not capable, i feel so stupid!
mybe i am typing in wrong keywords in googles search but i beg you
closed account (DSLq5Di1)
http://www.cplusplus.com/reference/algorithm/
http://www.cplusplus.com/reference/std/functional/
Read a book?
here:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include <iostream>
using namespace std;

int main(){
    int mylist[10];
	int temp;

	for(int n=0;n<10;n++)
	{
		cout << "Person " << n+1 << ", please enter how many pancakes you ate here: ";
		cin >> mylist[n];
	}
	
	for (int i=0; i<9; i++)    // element to be compared
    {
		for(int j = (i+1); j <10; j++)   // rest of the elements
		{
			if (mylist[i] < mylist[j])          // descending order
			{
				temp= mylist[i];          // swap
				mylist[i] = mylist[j];
				mylist[j] = temp;
			}
		}
	}
     
	for(int c=0;c<10;c++)
	{
		cout << mylist[c] << endl;
	}

	cout << endl << "biggie is " << mylist[0] << endl << endl;
	cout << "smallie is " << mylist[9] << endl << endl;
	
	system("pause");
	return 0;
}
i dont know how to thank you, sir!

i am sorry if i directly asked for an aswer but i really tried to avoid askinng because i know people who struggled learning this wouldnt appreciate it.

it is so confortable for me to study a piece of code rther than reading , but i dont mean that i dont like or i dont wan to read.
my current book im working with is "without fear". it had high rating and good reviews so i ordered it, and ofcourse t some points i need to look for the same chpters in tutorials mde by other programmers.

the program i was trying to make was for one of the few excersises someone posted in the forum.
it was one of the 5 star excersises (the part they asked to modify the program to sort them from biggest to smallest).
i was too curious to just skip it so i thought "ok, no problems, just some math!" but everything i tried just became messy and unreadable.

i dont know how to thank you. you saved alot of time and you took my frustration and threw it away! i would love to know if you need anything! even if i still am a nebie! but i feel sobad asking for direct answers :8 i am really sorry! but at the same time really happy tht you helped me!

sorry for typing this long but i really want to express myself how much i apprecitae your help and still it is not enough i know!

thANK YOU
Topic archived. No new replies allowed.