Zadatak 17

Sastaviti algoritam kojim se nalazi najveci od N unetih brojeva.

Algoritam

Zadatak

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

namespace ConsoleApplication1

{

class Program

{

static void Main(string[] args)

{

int n, x, max, i;

string opseg, ubroj, najveci;

Console.WriteLine("Unesite opseg brojeva, a zatim prvi broj:");

opseg = Console.ReadLine();

ubroj = Console.ReadLine();

n = Convert.ToInt32(opseg);

x = Convert.ToInt32(ubroj);

i = 1;

max = x;

while (i < n)

{

Console.WriteLine("Unesite sledeci broj:");

ubroj = Console.ReadLine();

x = Convert.ToInt32(ubroj);

if (x > max) max = x;

i = i + 1;

}

najveci = Convert.ToString(max);

Console.Write("Najveci broj je:" + najveci);

Console.ReadKey();

}

}

}