Maria Moreno

Generation

generate functionTue, 09 May 2023

En un club de atletismo se deben indicar las premiaciones mediante un programa así: Usando ciclos debe pedir por consola el número de competidores Ingresar por teclado los tiempos de cada competidor. Mostrar en consola los tres mejores tiempos, acompañados con el texto primer, segundo y tercer puesto con su respectivo puntaje. Nota: Los tiempos más cortos serán los ganadores

int cantidad = 0; string aux = ""; bool esNumero = false; Console.WriteLine("Ingrese la cantidad de competidores: "); aux = Console.ReadLine(); esNumero = int.TryParse(aux, out cantidad); int[] tiempos = new int[cantidad]; int i = 0; while (i < cantidad) { Console.WriteLine("Ingrese el tiempo del competidor " + (i + 1)); aux = Console.ReadLine(); esNumero = int.TryParse(aux, out tiempos[i]); i++; } //Ordenar los tiempos de menor a mayor int j = 0; while (j < cantidad - 1) { int k = j + 1; while (k < cantidad) { if (tiempos[j] > tiempos[k]) { //Intercambiar posiciones int aux

Want to kickstart your project?Use the new AI Studio to create your code