Advertisement
nevenailievaa

Задача 5: (Стр. 213 , Зад. 374):

Oct 23rd, 2022
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.63 KB | None | 0 0
  1. namespace Task374
  2. {
  3.     using System;
  4.     using System.Numerics;
  5.  
  6.     class Task374_1
  7.     {
  8.         static void Main(string[] args)
  9.         {
  10.             //first condition
  11.             int k = int.Parse(Console.ReadLine());
  12.  
  13.             bool isLoopExit = false;
  14.  
  15.             double sum = 0;
  16.  
  17.             while (!isLoopExit)
  18.             {
  19.                 double input = double.Parse(Console.ReadLine());
  20.                 sum += input;
  21.  
  22.                 if (input == 0)
  23.                 {
  24.                     isLoopExit = true;
  25.                 }
  26.             }
  27.  
  28.             Console.WriteLine(sum);
  29.  
  30.             //second condition
  31.  
  32.             double multiply = 1;
  33.  
  34.             for (int i = 0; i < 10; i++)
  35.             {
  36.                 double input = double.Parse(Console.ReadLine());
  37.  
  38.                 if (input >= 2 && input <= 12)
  39.                 {
  40.                     multiply *= input;
  41.                 }
  42.             }
  43.  
  44.             Console.WriteLine(multiply);
  45.  
  46.             //third condition
  47.  
  48.             int a = int.Parse(Console.ReadLine());
  49.             int b = int.Parse(Console.ReadLine());
  50.             int c = int.Parse(Console.ReadLine());
  51.  
  52.             BigInteger result = Sum(a * b) + Sum(c);
  53.  
  54.             Console.WriteLine(result);
  55.         }
  56.  
  57.         static BigInteger Sum(int k)
  58.         {
  59.             BigInteger evenSum = 0;
  60.  
  61.             Random rnd = new Random();
  62.  
  63.             for (int i = 0; i < k; i++)
  64.             {
  65.                 int num = rnd.Next(int.MinValue, int.MaxValue);
  66.  
  67.                 evenSum += num * (1 - (num % 2));
  68.             }
  69.  
  70.             return evenSum;
  71.         }
  72.     }
  73. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement