Advertisement
Guest User

Untitled

a guest
Nov 18th, 2019
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.76 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace Vezba_5
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int[] numbers = new int[] {1, 5, 9, 2, 6};
  14.             int max = FindLargestNum(numbers);
  15.             Console.WriteLine("Najveci u nizu je {0}", max);
  16.             Console.ReadKey();
  17.         }
  18.  
  19.         static int FindLargestNum(int[] numbers)
  20.         {
  21.             int max = numbers[0];
  22.             for (int i = 1; i<numbers.Length; i++)
  23.             {
  24.                 if (max < numbers[i])
  25.                 {
  26.                     max = numbers[i];
  27.                 }
  28.             }
  29.  
  30.             return max;
  31.         }
  32.     }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement