using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace aliniere
{
class elev
{
public char s;//B sau F
public int h, p;//inaltimea si pozitia
public bool maimic(elev e)
{//verific daca elevul curent < e
if (this.s > e.s)
return true;
if (this.s == e.s && this.h < e.h)
return true;
if (this.s == e.s && this.h == e.h
&& this.p<e.p)
return true;
return false;
}
}
class Program
{
static void citire(out elev[] E, out int n)
{
n = int.Parse(Console.ReadLine());
E = new elev[n + 1];
for(int i=1;i<=n;i++)
{
string l = Console.ReadLine();
string[] s = l.Split();
elev e = new elev();
e.s = s[0][0];//B sau F
e.h = int.Parse(s[1]);//inaltimea
e.p = i;//pozitia
E[i] = e;//adaug in E
}
}
static void inter(ref elev x, ref elev y)
{
elev aux = x;
x = y;
y = aux;
}
static void ordonare(ref elev[] E, int n)
{
for (int i = 1; i < n; i++)
for (int j = i + 1; j <= n; j++)
if (E[i].maimic(E[j]))
inter(ref E[i], ref E[j]);
}
static void Main(string[] args)
{
elev[] E;
int n;
citire(out E, out n);
ordonare(ref E, n);
for (int i = 1; i <= n; i++)
Console.Write(E[i].p + " ");
Console.ReadKey();
}
}
}
|