Skip to content

Instantly share code, notes, and snippets.

@vladholubiev
Created September 18, 2014 12:04
Show Gist options
  • Select an option

  • Save vladholubiev/e4c3de3276bff6013a32 to your computer and use it in GitHub Desktop.

Select an option

Save vladholubiev/e4c3de3276bff6013a32 to your computer and use it in GitHub Desktop.
Find a max and min number
#include <iostream>
using namespace std;
int main() {
int input[10] = {};
int max = 0;
int min = 0;
for (int i = 0; i < 10; i++) {
cin >> input[i];
}
for (int i = 0; i < 10; i++) {
if (input[i] > max) {
max = input[i];
}
}
min = max;
for (int i = 0; i < 10; i++) {
if (input[i] < min) {
min = input[i];
}
}
cout << "MAX: " << max << endl;
cout << "MIN: " << min << endl;
system("pause");
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment