Selection Sort Error

Write your question here.
Hey everyone I have a selection sort program but it only outputs what the user enters.
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
// Sort.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <iostream>
#include <vector>
using namespace std;
void Sort(vector<int>&input);

int _tmain(int argc, _TCHAR* argv[])
{
	vector <int> input;
	int number;
	cout<< "How many numbers do you want to enter?"<<endl;
	cin>> number;
	cout<< "Enter your numbers"<<endl;
	for(int x=0;x<number;x++)
	{
		int y;
		cin>> y;
		input.push_back (y);
	}
	Sort(input);
	for(int y=0;y<number;y++)
	{
		cout<< input[y] << " ";
	}
	return 0;
}
void Sort(vector<int>&input)
{
      for (	int start=0; start < input.size(); start++) {
            int index = start;
			int min=start;
            for (int j = start + 1; j < input.size(); j++)
			{
                  if (input[j] < input[index])
                  index = j;
			}
            if (min != start) {
                  int temp = input[start];
                  input[start] = input[index];
                  input[index] = temp;
            }
      }
Get rid of line 34 and fix line 40.

Hope this helps.
So what is wrong with line 40?
anyone?
At line 34 you set min equal to start. You then check if they are not equal at line 40. They will never not be equal. If you remove line 34 as suggested by Duoas, min will never be initialized to anything, and thus cannot be compared to start at line 40.
Topic archived. No new replies allowed.