Skip to content

Instantly share code, notes, and snippets.

@jakubkulhan
Created November 11, 2012 09:21
Show Gist options
  • Select an option

  • Save jakubkulhan/4054281 to your computer and use it in GitHub Desktop.

Select an option

Save jakubkulhan/4054281 to your computer and use it in GitHub Desktop.
Druhé minimum
int min, min2; // min2 je druhé minimum
if (N < 2) {
// pořeš, když tam je míň jak dvě hodnoty
} else {
if (pole[0] < pole[1]) {
min = pole[0];
min2 = pole[1];
} else {
min = pole[1];
min2 = pole[0];
}
for (i = 2; i < N; ++i) {
if (pole[i] < min) {
min2 = min;
min = pole[i];
} else if (pole[i] < min2) {
min2 = pole[i];
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment