C sharp - AYUDA ARREGLOS C# ORDENAMIENTO BURBUJA

 
Vista:
sin imagen de perfil

AYUDA ARREGLOS C# ORDENAMIENTO BURBUJA

Publicado por Daniela (1 intervención) el 15/05/2015 21:33:06
HOLA BUENAS TARDES. NECESITO UNA AYUDA CON EL ORDENAMIENTO BURBUJA, CUANDO ME HACE EL ORDENAMIENTO, EL ELEMENTO PRIMERO ME LO PONE EN CERO, COMO MUESTRA LA IMAGEN, Y SOLO ME ORDENA EL MENOR. LES AGRADECERÍA SU AYUDA.

CODIGO:

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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
namespace acciones
{
    public partial class Form1 : Form
    {
        int contador= 0 ;
        int cantidad;
        string nombre;
        string apellido;
        double[] valordeacciones;
        string[] nombrecompleto;
        string[] mujeres;
        double[] mujeresacciones;
        int contadorMujeres = 0;
        int contadorMujeresPlus = 1;
        int PlusContador;
        bool primeravez = true;
 
        public Form1()
        {
            InitializeComponent();
        }
 
        private void bttProcesar_Click(object sender, EventArgs e)
        {
            double PorcentajeMujeres;
            PorcentajeMujeres = (contadorMujeres * 100) / cantidad;
            txtAccionesMujeres.Text = PorcentajeMujeres.ToString() + "%";
            double PorcentajePlus;
            PorcentajePlus = (PlusContador * 100) / contadorMujeres;
            txtAccionesPlusM.Text = PorcentajePlus.ToString()+ "%";
            PlusBurbuja(mujeres, mujeresacciones);
            Mostar(mujeres, mujeresacciones);
 
            calcularMayor(nombrecompleto, valordeacciones);
            calcularMenor(valordeacciones, nombrecompleto);
        }
 
        private void bttInsertar_Click(object sender, EventArgs e)
        {
            cantidad = int.Parse(txtCantidad.Text);
            txtCantidad.Enabled = false;
            if (primeravez)
            {
                primeravez = false;
                nombrecompleto = new string[cantidad];
                valordeacciones = new double[cantidad];
            }
            nombre = txtNombre.Text;
            apellido = txtApellido.Text;
            nombrecompleto[contador] = apellido + "  " + nombre;
            valordeacciones[contador] = double.Parse(txtValorAcciones.Text);
            if (checkMujer.Checked == true)
            {
                contadorMujeres++;
            }
 
            if ((checkMujer.Checked == true) && (valordeacciones[contador] >= 100))
            {
                contadorMujeresPlus++;
                PlusContador = contadorMujeresPlus - 1;
                mujeres = new string[contadorMujeresPlus];
                mujeresacciones = new double[contadorMujeresPlus];
                mujeres[PlusContador - 1] = nombrecompleto[contador];
                mujeresacciones[PlusContador- 1] = valordeacciones[contador];
            }
            txtNombre.Clear();
            txtApellido.Clear();
            txtValorAcciones.Clear();
            checkMujer.Checked = false;
            checkHombre.Checked = false;
            contador++;
            if (contador >= cantidad)
            {
                bttInsertar.Enabled = false;
            }
        }
        private void PlusBurbuja(string[] mujeres, double[] mujeresaccciones)
        {
            string tempAlfabetico;
            double tempNumerico;
            int x = mujeresacciones.Length;
            for (int i = x - 1; i < 0; i--)
            {
                MessageBox.Show(" el valor de i o arreglo.length es :: " + i);
                for (int j = 0; j < i ; j++)
                {
                    if (mujeresaccciones[j] > mujeresaccciones[j + 1])
                    {
                        tempNumerico = mujeresaccciones[j];
                        mujeresaccciones[j] = mujeresaccciones[j + 1];
                        mujeresaccciones[j + 1] = tempNumerico;
                        tempAlfabetico = mujeres[j];
                        mujeres[j] = mujeres[j + 1];
                        mujeres[j + 1] = tempAlfabetico;
                    }
                }
            }
        }
        private void Mostar(string[] mujeres, double[] mujeresacciones)
        {
            txtList.Clear();
            for (int i = 0; i < mujeres.Length; i++)
            {
                txtList.AppendText(mujeres[i] + " " + mujeresacciones[i] + " " + "\r\n");
            }
        }namespace acciones
{
    public partial class Form1 : Form
    {
        int contador= 0 ;
        int cantidad;
        string nombre;
        string apellido;
        double[] valordeacciones;
        string[] nombrecompleto;
        string[] mujeres;
        double[] mujeresacciones;
        int contadorMujeres = 0;
        int contadorMujeresPlus = 1;
        int PlusContador;
        bool primeravez = true;
 
        public Form1()
        {
            InitializeComponent();
        }
 
        private void bttProcesar_Click(object sender, EventArgs e)
        {
            double PorcentajeMujeres;
            PorcentajeMujeres = (contadorMujeres * 100) / cantidad;
            txtAccionesMujeres.Text = PorcentajeMujeres.ToString() + "%";
            double PorcentajePlus;
            PorcentajePlus = (PlusContador * 100) / contadorMujeres;
            txtAccionesPlusM.Text = PorcentajePlus.ToString()+ "%";
            PlusBurbuja(mujeres, mujeresacciones);
            Mostar(mujeres, mujeresacciones);
 
            calcularMayor(nombrecompleto, valordeacciones);
            calcularMenor(valordeacciones, nombrecompleto);
        }
 
        private void bttInsertar_Click(object sender, EventArgs e)
        {
            cantidad = int.Parse(txtCantidad.Text);
            txtCantidad.Enabled = false;
            if (primeravez)
            {
                primeravez = false;
                nombrecompleto = new string[cantidad];
                valordeacciones = new double[cantidad];
            }
            nombre = txtNombre.Text;
            apellido = txtApellido.Text;
            nombrecompleto[contador] = apellido + "  " + nombre;
            valordeacciones[contador] = double.Parse(txtValorAcciones.Text);
            if (checkMujer.Checked == true)
            {
                contadorMujeres++;
            }
 
            if ((checkMujer.Checked == true) && (valordeacciones[contador] >= 100))
            {
                contadorMujeresPlus++;
                PlusContador = contadorMujeresPlus - 1;
                mujeres = new string[contadorMujeresPlus];
                mujeresacciones = new double[contadorMujeresPlus];
                mujeres[PlusContador - 1] = nombrecompleto[contador];
                mujeresacciones[PlusContador- 1] = valordeacciones[contador];
            }
            txtNombre.Clear();
            txtApellido.Clear();
            txtValorAcciones.Clear();
            checkMujer.Checked = false;
            checkHombre.Checked = false;
            contador++;
            if (contador >= cantidad)
            {
                bttInsertar.Enabled = false;
            }
        }
        private void PlusBurbuja(string[] mujeres, double[] mujeresaccciones)
        {
            string tempAlfabetico;
            double tempNumerico;
            int x = mujeresacciones.Length;
            for (int i = x - 1; i < 0; i--)
            {
                MessageBox.Show(" el valor de i o arreglo.length es :: " + i);
                for (int j = 0; j < i ; j++)
                {
                    if (mujeresaccciones[j] > mujeresaccciones[j + 1])
                    {
                        tempNumerico = mujeresaccciones[j];
                        mujeresaccciones[j] = mujeresaccciones[j + 1];
                        mujeresaccciones[j + 1] = tempNumerico;
                        tempAlfabetico = mujeres[j];
                        mujeres[j] = mujeres[j + 1];
                        mujeres[j + 1] = tempAlfabetico;
                    }
                }
            }
        }
        private void Mostar(string[] mujeres, double[] mujeresacciones)
        {
            txtList.Clear();
            for (int i = 0; i < mujeres.Length; i++)
            {
                txtList.AppendText(mujeres[i] + " " + mujeresacciones[i] + " " + "\r\n");
            }
        }

FOTO
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder