Advertisement
Guest User

Untitled

a guest
Dec 12th, 2018
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.38 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text.RegularExpressions;
  5.  
  6. namespace Rextester
  7. {
  8.     public class Program
  9.     {
  10.         public static void Main(string[] args)
  11.         {
  12.             double[] a = new double[30];
  13.             int [] b = new int[30];
  14.             double[] c = new double[30];
  15.             int i, n1, n2, n3;
  16.             double x;
  17.             Console.Write("vvedite n1:");
  18.             Console.WriteLine();
  19.             n1 = int.Parse(Console.ReadLine());
  20.             Console.Write("vvedite n2:");
  21.             n2 = int.Parse(Console.ReadLine());
  22.             Console.Write("vvedite n3:");
  23.             n3 = int.Parse(Console.ReadLine());
  24.             Console.WriteLine();
  25.                 if (( n1 == n2)&&(n1 == n3)) {
  26.                 Console.Write("nuzhno vvesti raznie n"); return; }
  27.             Random rand = new Random();
  28.             for (i=0; i< n1; i++)
  29.             {
  30.                 b[i] = rand.Next(-15, 15);
  31.                 Console.Write("b[" + i + "]= " + b[i].ToString());
  32.                 Console.WriteLine();
  33.             }
  34.             Console.WriteLine();
  35.            
  36.            for (i=0; i<n2; i++)
  37.            {
  38.                try
  39.                {
  40.                    for (x = - 2; x <=4; x= x + 0.3)
  41.                    {
  42.                      a[i] = Math.Log(1/(x+1));
  43.                    }
  44.                catch(IndexOutOfRangeException)
  45.                {
  46.                    a[i] =0;
  47.                }
  48.                    catch(DivideByZeroException)
  49.                    {
  50.                        a[i] =0;
  51.                    }
  52.                    Console.Write("a[" + i + "]= " + a[i].ToString());
  53.                 Console.WriteLine();
  54.                }
  55.                 Console.WriteLine();
  56.                for( i=0; i<n3; i++)
  57.                {
  58.                    try
  59.                    {
  60.                        c[i] = a[i]/b[i+1];
  61.                    }
  62.                   catch(IndexOutOfRangeException)
  63.                {
  64.                    c[i] =0;
  65.                }
  66.                    catch(DivideByZeroException)
  67.                    {
  68.                        c[i] =0;
  69.                    }  
  70.                
  71.                Console.Write("c[" + i + "]= " + c[i].ToString());
  72.                Console.WriteLine();
  73.                
  74.                }
  75.                Console.ReadLine();
  76.            
  77.         }
  78.     }
  79. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement