Anderson Pozo

Generation

generate functionSun, 25 Jun 2023

Hacer un programa para ingresar una lista de números que finaliza cuando se ingresa un cero, luego informar el máximo y la posición dentro de la lista.

#include <iostream> using namespace std; int main() { int n, pos_max = 0, max = 0; do { cin >> n; if (n > max) { max = n; pos_max = 0; } if (n == max) { pos_max++; } } while (n != 0); cout << max << " " << pos_max << endl; return 0; }

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