Array ordering and printing

Hello all,

Have been attempting a very silly exercise concerning arrays and pancakes.

Just trying to get the basics of my array ordering to work. I was so sure that this would work to print out the pancake numbers in descending order. It looks good to me, but doesn't print out a thing.

Have been working on it long enough now to know when to ask for a hint. Here is the code:

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
#include <algorithm>  //for swap function
#include <iostream>
#include <string>
#include <limits>

using namespace std;

int main ()
{
 
int array [10]; 	//the 10 peoples pankake amounts	

int smallest_spot;				//variable for smallest position
int start_place =0;				//variable for start place
int current_place; 						//variable for current location in the array

int person =1;									//variable for which customer
int x;

cout << "How many pancakes did person 1 eat?" << endl;

while ((cin >> array[start_place]) && person!=10)				//puts the info into
	{															//the array
	person++;
	start_place++;
	cout << "How many pancakes did person " << person << " eat? \n";
	}
	
// step through the array
for (start_place =0; start_place <10; start_place++)
	{
	smallest_spot = start_place;		// initiates position 0 as smallest spot
	
	for (current_place = start_place +1; current_place < 10; current_place ++)
		{
		if (array[current_place] < array[smallest_spot])
		smallest_spot = current_place;
		}
	swap (array[start_place], array[smallest_spot]);
	}
	
for (x=9; x==0; x--)
	{
	cout << array[x] <<endl;
	}
	return 0;
	}


I'm probably too tired to spot the error. Any suggestions please, I'm turning in for the night. Will report back tomorrow - many thanks in advance,

Dan
Topic archived. No new replies allowed.