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 arrayUmn
- {
- class Program
- {
- public static int arraySize()
- {
- int n = 0;
- bool check = false;
- while (!check)
- {
- try
- {
- Console.Write("Введите размер массива:");
- n = int.Parse(Console.ReadLine());
- check = true;
- }
- catch
- {
- Console.WriteLine("Повторите ввод!");
- check = false;
- }
- }
- return n;
- }
- public static double[] arrayFilling(int n)
- {
- double[] array = new double[n];
- bool check = false;
- for (int i = 0; i < n; i++)
- {
- while (!check)
- {
- try
- {
- Console.Write("[" + i + "]" + ":");
- array[i] = double.Parse(Console.ReadLine());
- check = true;
- }
- catch
- {
- Console.WriteLine("Повторите ввод!");
- check = false;
- }
- }
- check = false;
- }
- return array;
- }
- public static double arrayUmn(double[] array, int start, int finish)
- {
- double arrUmn = 1;
- for (int i = start; i < finish; i++)
- {
- arrUmn *= array[i];
- }
- return arrUmn;
- }
- static void Main(string[] args)
- {
- try
- {
- int n = arraySize();
- double[] array = arrayFilling(n);
- Console.WriteLine("Произведение:" + arrayUmn(array, 1, array.Length - 1));
- }
- catch
- {
- Console.WriteLine("Даже я не знаю что тут могло сломаться:)");
- }
- Console.ReadKey();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement