using System;
using System.Security.Cryptography.X509Certificates;
namespace MetodoOrdenamientoBurbuja
{
class Burbuja {
int[] numeros = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
int i, j, aux, n = 10;
public void ingresarDatos()
{
Console.WriteLine("Please sir, user, enter the following information");
for (i = 0; i < 10; i++)
{
try
{
Console.WriteLine("enter a number");
numeros[i] = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("valor" + i);
}
catch (Exception ex)
{
i = i - 1;
Console.WriteLine("Mistake! The value entered is not a number");
}
}
}
public void Ordenar()
{
Console.WriteLine("The entered data will be sorted by the bubble method");
for (i = 0; i <= n; i++)
{
for(j = 0; j<n-1; j++)
{
if (numeros[j] > numeros[j + 1])
{
aux = numeros[j];
numeros[j]= numeros[j+1];
numeros[j+1]= aux;
}
}
}
public void Mostrar()
{
try
{
string NombreDeArchivo = "JoinerBurbuja.txt";
StreamWriter Write=File.AppendText(NombreDeArchivo);
Console.WriteLine("The ordered values in the array are:");
Write.WriteLine("The information that is executed in the code will be saved in
the file");
for (i=0; i<n; i++)
{
Console.WriteLine(numeros[i]);
Write.WriteLine(numeros[i]);
}
Write.Close();
}
catch
{
Console.WriteLine("Could not save information");
}
static void Main(String[] args)
{
Burbuja obj = new Burbuja();
obj.ingresarDatos();
obj.Ordenar();
obj.Mostrar();
}
}
}