Advertisement
Guest User

Untitled

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