|
Mostrar Mensajes
|
Páginas: [1]
|
2
|
Programación / .NET (C#, VB.NET, ASP) / Re: ayuda*¨ejercio c sharp
|
en: 26 Noviembre 2011, 20:33 pm
|
esto es como voy haciendo... llego hasta ordenar los elementos y ponerlos en orden... pero para hacerlo en forma triangular no me sale
namespace algoritmo_burbuja { class burbuja_array { static void Main(string[] args) { int i, j, aux, n; string auxn; Console.WriteLine("ingrese cantidad de elementos"); n = int.Parse(Console.ReadLine()); Console.WriteLine("ingrese ahora los elementos"); string[] nombre = new string[10]; int[] a = new int[10];
for (i = 1; i <= n; i++) { // Console.WriteLine("ingrese elnombre"); // nombre = Console.ReadLine(); Console.WriteLine("ingrese nota"); a = int.Parse(Console.ReadLine());
} for (i = 1; i <= n; i++) { j = n; while (j > i) { if (a[j - 1] >= a[j]) { aux = a[j - 1]; auxn = nombre[j - 1]; a[j - 1] = a[j]; nombre[j - 1] = nombre[j]; a[j] = aux; nombre[j] = auxn; } j = j - 1; } } for (i = 1; i <= n; i++) { //Console.WriteLine(); Console.WriteLine("{0}", a); } for (int t = 0; i < 3; t++) {
for (int l = i; l <3; l++) {
Console.Write(" ");
} for (int s = 2 * i + 1; s > 0; s--) { Console.Write("*",a); } Console.WriteLine(""); Console.ReadKey(); }
verTriángulo(a); Console.ReadKey(); }
static void verTriángulo(int N) { for (int n = 0; n <= N; ++n) { for (int i = 0; i < N - n; ++i) Console.Write("{0,4}", ""); for (int p = 0; p <= n; ++p) Console.Write("{0,4}{1,4}",p); Console.WriteLine(); } }
} }
espero que me ayuden y gracias de antemano.
|
|
|
3
|
Programación / .NET (C#, VB.NET, ASP) / ayuda*¨ejercio c sharp
|
en: 26 Noviembre 2011, 19:20 pm
|
bueno.. aver si me ayudan..
ingresar "n" cantidad de elementos numericos y ordenarlos de menor a mayor y que los muestre en forma del triangulo de pascal
ej: 1,2,3,46,6,7,8,97,88
debe salir 1 2 3 6 7 8 46 88 97
|
|
|
|
|
|
|