Skip to content

Instantly share code, notes, and snippets.

@juanfal
Created October 24, 2012 12:35
Show Gist options
  • Save juanfal/3945832 to your computer and use it in GitHub Desktop.
Save juanfal/3945832 to your computer and use it in GitHub Desktop.
máx y mín de números hasta cero
// maxminhasta0.cpp
// juanfc 2012-06-24
//
#include <iostream>
using namespace std;
void maxmin(int& min, int& max);
int main()
{
int M, m;
maxmin(m, M);
cout << "Mínimo: " << m << endl;
cout << "Máximo: " << M << endl;
return 0;
}
void maxmin(int& min, int& max)
{
int n;
cin >> n;
min = max = n;
while (n != 0) {
cin >> n;
if (n > max)
max = n;
if (n < min)
min = n;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment