Created
October 24, 2012 12:35
-
-
Save juanfal/3945832 to your computer and use it in GitHub Desktop.
máx y mín de números hasta cero
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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