Nikolcho

2 задача

May 20th, 2020
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.80 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace _02.Sum_of_2_arrays
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             Console.WriteLine("Write end point: ");
  14.             int end = int.Parse(Console.ReadLine());
  15.  
  16.             double[] first = new double[end];
  17.             double[] second = new double[end];
  18.             double sum = 0;
  19.  
  20.             for (int i = 0; i < end; i++)
  21.             {
  22.                 first[i] = i + 1;
  23.                 second[i] = i + 1;
  24.             }
  25.  
  26.             for (int i = 0; i < end; i++)
  27.             {
  28.                 sum += Math.Pow(first[i], 2) + Math.Pow(second[i], 2);
  29.             }
  30.  
  31.             Console.WriteLine(sum);;
  32.         }
  33.     }
  34. }
Add Comment
Please, Sign In to add comment