Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Lab1_2
- {
- /*
- ** author: Damjan Miloshevski, CEO & Founder
- ** occupation: mobile, software and web developer
- ** contact: d.miloshevski@gmail.com;+38978566409;
- ** web: https://www.facebook.com/damjan.miloshevski;
- */
- class Program
- {
- static void Main(string[] args)
- {
- System.Console.WriteLine("---------------- Programa za broevi. Voved vo C#! ----------------\n");
- System.Console.WriteLine("Izberi:\n");
- System.Console.WriteLine("1 - Vnesuvaj\n");
- System.Console.WriteLine("2 - Generiraj avtomatski\n");
- System.Console.WriteLine("3 - Izlez\n");
- System.Console.WriteLine("Vashiot izbor: ");
- int choice = Convert.ToInt32(System.Console.ReadLine());
- switch (choice)
- {
- case 1:
- {
- System.Console.WriteLine("\n----- Izbravte sami da vnesuvate ----- \n");
- int n, sum = 0, vrednost;
- int min = int.MaxValue;
- int max = int.MinValue;
- double avg = 0;
- System.Console.WriteLine("Vnesete opseg:");
- n = Convert.ToInt32(System.Console.ReadLine());
- System.Console.WriteLine("\nVnesete gi broevite:");
- for (int i = 0; i < n; i++)
- {
- vrednost = Convert.ToInt32(System.Console.ReadLine());
- sum += vrednost;
- avg = sum / n;
- if (vrednost != 0)
- {
- if (max < vrednost)
- {
- max = vrednost;
- }
- if (min > vrednost)
- {
- min = vrednost;
- }
- }
- }
- System.Console.WriteLine("\nSuma = {0}, Prosek = {1}, Minimum = {2}, Maximum = {3}", sum, avg, min, max);
- System.Console.WriteLine("\nPritisnete bilo koe kopce za da izlezete");
- break;
- }
- case 2:
- {
- System.Console.WriteLine("\n----- Izbravte avtomatski da generira broevi ----- \n");
- Random rand = new Random();
- int min = int.MaxValue;
- int max = int.MinValue;
- int sum = 0;
- int avg = 0;
- for (int i = 1; i <1001; i++)
- {
- int n = rand.Next(1,1000);
- if (n != 0)
- {
- if (min > n)
- {
- min = n;
- }
- if (max < n)
- {
- max = n;
- }
- }
- sum += n;
- avg = sum / 1000;
- }
- System.Console.WriteLine("\nSuma = {0}, Prosek = {1}, Minimum = {2}, Maximum = {3}", sum, avg, min, max);
- System.Console.WriteLine("\nPritisnete bilo koe kopce za da izlezete");
- break;
- }
- case 3:
- {
- System.Console.WriteLine("\n----- Izbravte Izlez -----");
- System.Console.WriteLine("\nPritisnete bilo koe kopce za da izlezete");
- break;
- }
- }
- System.Console.ReadKey();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement