organize array of objetc in OOP descending

Hi good afternoon, well my program is about of a atraction park (like disneyland) where any atraction have 2 values, 1 string with their name and the fun level, example:
roller_coster 10
terror_house 80
crazy_cups 30

my program read 3 things, m (quantity) 1<=M<=100000, n (the most popular atraccion, are that atraction with more fun level) and h (this part still don't use now in my program)

in my program read the atraction until m , but I have to organize the atraction for popular n;
example:
roller_coster 10
terror_house 80
crazy_cups 30

exit:

terror_house
crazy_cups
roller_coaster

but the momnet to run my program don't do nothing, read the name and fun level but no show me something , please can you help me with this program?

I use the selection sort for organize the array, so I don't know if the code is good, but I based in these way for the organize it

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
61
62
63
64
65
66
67
68
69
70
71
72
73

#include <iostream>
#include <string>
using namespace std;

class atraccion {
	private:
	int x;
	string name;
	public:
	
	atraccion () {} 
	atraccion (int var, string nnombre){
		x=var;
		name = nnombre;
	}
	~atraccion() {}
	
	void set_x (int val) { 				//modifica el x
		x = val;
	}
	
	int get_x () {						//devuelve el x
		return x;
	}
	
	void set_name ( string nom) {			//modifica el nombre
		name =nom;
	}
	
	string get_name () {					//devuelve el nombre
		return name;
	}
};



int main (){
	int m, n, h,div;
	int posmayor,mayor;
	string nombre;
	atraccion ar [100000];				//arreglo que almacena cada atraccion 
	
	cin>>m>>n>>h;
	
		for (int i=0;i<m;i++) {
			cin>>nombre;
			cin>>div;
			ar[i].set_name(nombre);
			ar[i].set_x (div);
		}
		
		for (int h=0;h<=m-1;h++){				//ordenamiento 
			posmayor = h;
			mayor = ar[h].get_x();
			for (int k=h+1; k<=m; k++){
				if (ar[k].get_x() > mayor) {
					mayor = ar[k].get_x();
					posmayor =k;
				}
			}
			ar[posmayor] = ar[h];
			ar[h].set_x(mayor);
		}
		
		for (int j=0;j<n;j++) {
			cout<<ar[j].get_name()<<endl;
		}
	
	return 0;
}

Topic archived. No new replies allowed.