DamSi

Untitled

Mar 8th, 2015
234
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.35 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 Lab1_6
  8. {       /*
  9.           ** author: Damjan Miloshevski
  10.           ** contact: [email protected];
  11.           ** skype: damjan.milosevski
  12.           ** phone: +38978566409;
  13.           ** web: https://www.facebook.com/damjan.miloshevski
  14.                 http://miloshevski.us.to/
  15.         */
  16.     class Program
  17.     {
  18.         static void Main(string[] args)
  19.         {
  20.             Random n = new Random();
  21.             int broj;
  22.             double sum = 0;
  23.             int min = int.MaxValue;
  24.             int max = int.MinValue;
  25.             double avg = 0;
  26.             for (int i = 1; i < 1001; i++)
  27.             {
  28.                 broj = n.Next(1, 1000);
  29.                 if (broj > max)
  30.                 {
  31.                     max = broj;
  32.                 }
  33.                 if (broj < min)
  34.                 {
  35.                     min = broj;
  36.                 }
  37.                 sum += broj;
  38.                 avg = sum / 1000;
  39.             }
  40.             Console.WriteLine(string.Format("Suma = {0:#.##}, Prosek = {1:#.##}, Minimum = {2}, Maximum = {3}", sum, avg, min, max));
  41.             Console.WriteLine();
  42.             Console.WriteLine("Pritisnete bilo kopce da izlezete.");
  43.             Console.ReadKey();
  44.         }
  45.     }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment