Red de conocimiento informático - Conocimiento sistemático - Programación de búsqueda 30

Programación de búsqueda 30

# incluir & ltiostream & gt

# incluir & ltvector & gt

# incluir & ltutilities& gt

# incluir & ltalgoritmo& gt

int my _ CMP(STD::par & lt; largo, doble & gtp1, STD::par & lt; largo, doble & gtp2)

{

return p 1 . segundo & gt; p2.segundo

}

void read _ data(STD::vector & lt; STD::par & lt;long, double & gt& gt& ampStudio, int n)

{

Identificación larga;

Integral doble;

int I = 0

mientras; (i++ & lt; N)//Ingresar información del estudiante

{

STD::cout & lt;& lt"Ingresar estudiante[" & lt;& ltI& lt& lt"] ID:" //Ingrese el número de estudiante.

Y (! (STD::CIN & gt; & gtid))

{

STD::CIN clear();

.

while (std::cin.get()!= '\n ')

Continuar;

STD::cout & lt;& ltID error, vuelva a ingrese :

}

STD::CIN . get();

STD::cout <<"Ingrese estudiante["<& lti<<" ]Puntuación:";//Ingrese la puntuación del estudiante

Y (!(STD::CIN>>Score))

{

STD::CIN . clear ();

mientras (std::cin.get()!= '\n ')

Continuar;

STD::cout & lt; & lt\nError principal, ingrese nuevamente: ";

}

stu . push _ back(STD::make _ pair( id, scoring));

}

sort(stu.begin(), stu.end(), mi _ CMP

}

void print _ data(const); STD::vector & lt; STD::pair & lt; long, double & gt& gt& ampStu, int n)// Genera la información ordenada del estudiante

<. :cout <<”\n -información de puntuación-\n”;

STD::cout ancho(25);

STD::cout & lt;& lt" ID de estudiante";

STD::cout . width(5);

STD::cout & lt;& lt"logro"

for(int I = 0;i<n;i++)

{

STD::cout ancho(25);

STD::cout <<stud[i] .

STD::cout .width(5);

STD: :cout <<stud[i].

Segundo& lt& ltSTD::endl;

}

}

int main()

{

int n;

STD::cout<<"Ingrese el número de estudiantes:";

STD::CIN>>n;

STD::vector< STD::pair<long,double>>student;

read_data(estudiante, n);

print_data(estudiante, n) ;

Devuelve 0;

}