viernes, 14 de mayo de 2010

PROYECTO ORDENACION

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ProyectOrdenacion
{
class Alumno
{
int n;
int []Notas;
String[] Nombre;
Alumno(int p) {
n = p;
Notas = new int[n];
Nombre = new String[n];
}
public void Ingreso() {
for (int i = 0; i < n; i++)
{
Console.WriteLine("Alumno{0}: ",(i+1));
Nombre[i] = Console.ReadLine();
Console.WriteLine("Nota:");
Notas[i] = int.Parse(Console.ReadLine ());
}
}
public void OrdenarBurbuja() {
int aux;
String auxNom;
for (int i = 0; i < n-1;i++ )
{
for (int j = i+1; j < n;j++ )
{
if (Notas[j] > Notas[i])
{
aux = Notas[i];
Notas[i] = Notas[j];
Notas[j] = aux;
auxNom = Nombre[i];
Nombre[i] = Nombre[j];
Nombre[j] = auxNom;
}
}
}
}
public void Mostrar()
{
Console.WriteLine ("NOMBRE\tNOTA");
for (int i=0;i Console.WriteLine("{0}\t{1}",Nombre[i],Notas [i]);
Console.WriteLine("Pulse una tecla para continuar.");
Console.ReadKey();
}
static void Main(string[] args)
{
int a;
Console.WriteLine("Ingrese cantidad alumnos:");
a = int.Parse(Console.ReadLine());
Alumno a1=new Alumno (a);
a1.Ingreso();
a1.Mostrar();
a1.OrdenarBurbuja();
a1.Mostrar();
Console.ReadLine();
}
}
}

No hay comentarios:

Publicar un comentario

*Dejanos Tus Comentarios*