Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace Task374
- {
- class Program
- {
- static void Main(string[] args)
- {
- /* Generate random numbers between 375 and 423
- Random randomGen = new Random();
- for (int i = 0; i < 130; i++)
- {
- var number = randomGen.Next(375, 423);
- if (number == 394) continue;
- Console.WriteLine(number);
- }
- return;
- */
- Console.Write("Please, enter k = ");
- int k = int.Parse(Console.ReadLine());
- Console.WriteLine("The sum of not null numbers is: {0}", InputNumbers());
- //2.
- int[] array4Mul = new int[10];
- InputNumbers2(array4Mul);
- Console.WriteLine("The mul in the interval [2,12] is {0}", MulInInterval(array4Mul, 2, 12));
- // 3.
- Console.Write("Please enter a = ");
- int a = int.Parse(Console.ReadLine());
- Console.Write("Please enter b = ");
- int b = int.Parse(Console.ReadLine());
- Console.Write("Please enter c = ");
- int c = int.Parse(Console.ReadLine());
- Console.WriteLine(Sum(a * b) + Sum(c));
- }
- static int InputNumbers()
- {
- int sum = 0;
- int number = 0;
- do
- {
- Console.Write("Please, enter the next number (0 for end): ");
- number = int.Parse(Console.ReadLine());
- if (number != 0 )
- {
- sum += number;
- }
- } while (number != 0);
- return sum;
- }
- static void InputNumbers2(int[] array)
- {
- for (int i = 0; i < array.Length; i++)
- {
- Console.Write("Please, enter element[{0}] = ", i);
- array[i] = int.Parse(Console.ReadLine());
- }
- }
- static int MulInInterval(int[] array, int min, int max)
- {
- int mul = 1;
- for (int i = 0; i < array.Length; i++)
- {
- if (array[i] >= min && array[i] <= max)
- {
- mul *= array[i];
- }
- }
- return mul;
- }
- static int Sum(int k)
- {
- int sum = 0;
- Random randomGen = new Random();
- int[] array = new int[k];
- for (int i = 0; i < array.Length; i++)
- {
- array[i] = randomGen.Next();
- if (array[i] % 2 ==0)
- {
- sum += array[i];
- }
- }
- return sum;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement