Advertisement
Guest User

Untitled

a guest
Nov 17th, 2019
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.96 KB | None | 0 0
  1.  
  2. using System;
  3.  
  4. public class program
  5. {
  6.    public static double sred(int k)
  7.    {
  8.        double srednoArr=0;
  9.        int brr3=0;
  10.        double sum3=0;
  11.        Random rnd = new Random();
  12.        int[] numbers = new int[k];
  13.        for(int i=0;i<k;i++)
  14.        {
  15.            numbers[i] = rnd.Next(1,1000);
  16.            if(numbers[i]>=10||numbers[i]<=100)
  17.            {
  18.                sum3 += numbers[i];
  19.                brr3++;
  20.            }
  21.        }
  22.        srednoArr = sum3/brr3;
  23.        return srednoArr;
  24.    }
  25.     public static void Main(string[] args)
  26.     {  
  27.         int a,b,c;
  28.         double result;
  29.         Console.WriteLine("Моля въведете число а: ");
  30.         a = int.Parse(Console.ReadLine());
  31.         Console.WriteLine("Моля въведете число b: ");
  32.         b = int.Parse(Console.ReadLine());
  33.         Console.WriteLine("Моля въведете число c: ");
  34.         c = int.Parse(Console.ReadLine());
  35.        
  36.         result = sred(Math.Abs(c-b))-sred(c+a);
  37.         Console.WriteLine("Резултатът е ");
  38.         Console.WriteLine(result);
  39.     }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement