Help with making a sorting 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
43
44
45
46
#include<iostream>
#include<fstream>
#include<iomanip>
#include<stdio.h>
#include<stdlib.h>
#include<cstring>
using namespace std;
void Sorting();
int main()
{
	//int i;
	int n; // number of salaries
	string Occupation;
	double Salaries;
	double Median;
	double Average;
	string fname;
	ifstream input;
	ofstream output;

	//Intro
	cout << "Welcome to this program.\n";	 
	cout << "Please enter text file you use.\n";
	cin >> fname;
	//Opening file if acceptable
	input.open(fname.c_str() );

	if(input.fail())
	{
		cout << "Not a valid filename\n"; 
		exit(0);
	}
	//cout.setf(ios::fixed || ios::showpoint);
	//cout.precision(2);
	
      //  while (!input.eof())
        {
                input >> Occupation;
                input >> Salaries; 
	}
	output.open("output.txt");
}
/* Function Name: Ascending order 
 * Input:
 * Output:
*/


make it sort ascening wise for salaries and have the occupation sort with it.
Last edited on
That doesn't help, I already have a book for that. Thanks anyways...I guess
closed account (D80DSL3A)
Sort what? You've declared only one salary and one occupation.
Try getting your input and data storage right before you worry about sorting.
That doesn't help, I already have a book for that. Thanks anyways...I guess

Sorry I didn't just give you the answer. The sorts in the links I gave you -- and in your book, presumably -- are the simplest sorting functions in existence. If you want to sort something, you're going to have to spend some time reading your book and trying to do it. Not being rude to those who offer help.

I guess you are going to have to use your brain.
why are programmers one of the most rude/coldest peoples I know.
I don't know. So why is it you are being so rude then?

You asked for help, and short of giving you code to do the work I've offered you two possible answers. You wanna talk about rudeness? Being rude is refusing to accept help because it isn't what you wanted, and being ungracious about it on top.

Programming is a thinking occupation -- if you want to program, you'll have to do some thinking for yourself instead of half-heartedly griping that someone didn't spell it out for you step-by-step.

So maybe it's because programmers are less likely to put up with rude crap than most people, especially when they volunteer their time to help you wrap your brain around it all. And after the way you have treated me here, why would anyone else volunteer their time to try to help you?
Topic archived. No new replies allowed.