Created
November 11, 2012 09:21
-
-
Save jakubkulhan/4054281 to your computer and use it in GitHub Desktop.
Druhé minimum
This file contains hidden or 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
| 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