Advertisement
DamSi

Untitled

Feb 28th, 2015
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 4.19 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_2
  8. {
  9.  
  10.     /*
  11.         ** author: Damjan Miloshevski, CEO & Founder
  12.         ** occupation: mobile, software and web developer
  13.         ** contact: d.miloshevski@gmail.com;+38978566409;
  14.         ** web: https://www.facebook.com/damjan.miloshevski;
  15.     */
  16.     class Program
  17.     {
  18.         static void Main(string[] args)
  19.         {
  20.             System.Console.WriteLine("---------------- Programa za broevi. Voved vo C#! ----------------\n");
  21.             System.Console.WriteLine("Izberi:\n");
  22.             System.Console.WriteLine("1 - Vnesuvaj\n");
  23.             System.Console.WriteLine("2 - Generiraj avtomatski\n");
  24.             System.Console.WriteLine("3 - Izlez\n");
  25.             System.Console.WriteLine("Vashiot izbor: ");
  26.  
  27.             int choice = Convert.ToInt32(System.Console.ReadLine());
  28.            
  29.             switch (choice)
  30.             {
  31.                 case 1:
  32.                     {
  33.                         System.Console.WriteLine("\n----- Izbravte sami da vnesuvate ----- \n");
  34.                         int n, sum = 0, vrednost;
  35.                         int min = int.MaxValue;
  36.                         int max = int.MinValue;
  37.                         double avg = 0;
  38.                         System.Console.WriteLine("Vnesete opseg:");
  39.                         n = Convert.ToInt32(System.Console.ReadLine());
  40.                         System.Console.WriteLine("\nVnesete gi broevite:");
  41.                         for (int i = 0; i < n; i++)
  42.                         {
  43.                             vrednost = Convert.ToInt32(System.Console.ReadLine());
  44.                             sum += vrednost;
  45.                             avg = sum / n;
  46.                             if (vrednost != 0)
  47.                             {
  48.                                 if (max < vrednost)
  49.                                 {
  50.                                     max = vrednost;
  51.                                 }
  52.                                 if (min > vrednost)
  53.                                 {
  54.                                     min = vrednost;
  55.                                 }
  56.                             }
  57.                         }
  58.                         System.Console.WriteLine("\nSuma = {0}, Prosek = {1}, Minimum = {2}, Maximum = {3}", sum, avg, min, max);
  59.                         System.Console.WriteLine("\nPritisnete bilo koe kopce za da izlezete");
  60.                         break;
  61.                     }
  62.                 case 2:
  63.                     {
  64.                         System.Console.WriteLine("\n----- Izbravte avtomatski da generira broevi ----- \n");
  65.                         Random rand = new Random();
  66.                         int min = int.MaxValue;
  67.                         int max = int.MinValue;
  68.                         int sum = 0;
  69.                         int avg = 0;
  70.                         for (int i = 1; i <1001; i++)
  71.                         {  
  72.                             int n = rand.Next(1,1000);
  73.                             if (n != 0)
  74.                             {
  75.                                 if (min > n)
  76.                                 {
  77.                                     min = n;
  78.                                 }
  79.                                 if (max < n)
  80.                                 {
  81.                                     max = n;
  82.                                 }
  83.                             }
  84.                             sum += n;
  85.                             avg = sum / 1000;
  86.                         }
  87.                         System.Console.WriteLine("\nSuma = {0}, Prosek = {1}, Minimum = {2}, Maximum = {3}", sum, avg, min, max);
  88.                         System.Console.WriteLine("\nPritisnete bilo koe kopce za da izlezete");
  89.                         break;
  90.                     }
  91.                 case 3:
  92.                     {
  93.                         System.Console.WriteLine("\n----- Izbravte Izlez -----");
  94.                         System.Console.WriteLine("\nPritisnete bilo koe kopce za da izlezete");
  95.                         break;
  96.                     }
  97.             }
  98.             System.Console.ReadKey();
  99.         }
  100.     }
  101. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement