SHOW:
|
|
- or go back to the newest paste.
| 1 | //Rask paskutinę didžiausią reikšmę. | |
| 2 | ||
| 3 | - | static int Max (int[] M) |
| 3 | + | static int Max (int[] M) |
| 4 | {
| |
| 5 | int max=0; | |
| 6 | int index=0; | |
| 7 | for(int i=0; i<M.Length; i++) | |
| 8 | {
| |
| 9 | if(max<M[i]) | |
| 10 | {
| |
| 11 | max=M[i]; | |
| 12 | index=i; | |
| 13 | } | |
| 14 | if(max==M[i] && index<i) | |
| 15 | {
| |
| 16 | index=i; | |
| 17 | max=M[index]; | |
| 18 | } | |
| 19 | } | |
| 20 | return max; | |
| 21 | } |