Fandom

Scratchpad

PLE:Unidad4Ejercicio04

219,576pages on
this wiki
Add New Page
Discuss this page0 Share
/*
Programa:         Unidad4Ejercicio04.cpp
Fecha:            21/11/2006
Descripción:      Lee un array de 10 enteros y muestra el mayor y el menor.

*/
#include <iostream>
#include <conio>
#include <stdlib>
using namespace std;

const int NUM = 5;

void maximo(int n[], int &m, int &p);

void main()
{
      int num[NUM], i;
      int m, p; // máximo y posición

      for(i = 0; i < NUM; i++)
      {
            cout << "Introduzca un numero " ;
            cin >> num[i];
      }

      maximo(num,m,p);

      cout << "El maximo es = " << m << " y la posicion es = " << p;

      cin.ignore();
      cin.get();
}

void maximo(int n[], int &m, int &p)
{
      int i;
      m = n[0];
      p = 0;
      for(i = 1; i < NUM; i++)
      {
            if(n[i] > m)
            {
                  m = n[i];
                  p = i;
            }
      }
}

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.

Also on Fandom

Random wikia