Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace ConsoleApp21
- {
- class Program
- {
- static void Main(string[] args)
- {
- double[] va = new double[] { 1, 2, 3, 11 };
- double[] vb = new double[] { 4, 5, 6, 22 };
- double[] vc = Add(va, vb);
- Print(va);
- Print(vb);
- Print(vc);
- }
- private static double[] Add(double[] vectorA, double[] vectorB)
- {
- if (vectorA.Length != vectorB.Length)
- {
- return null;
- }
- double[] vectorC = new double[vectorA.Length];
- for (int i = 0; i < vectorC.Length; i++)
- {
- vectorC[i] = vectorA[i] + vectorB[i];
- }
- return vectorC;
- }
- private static void Print(double[] vector)
- {
- Console.Write("{ ");
- foreach (double d in vector)
- {
- Console.Write(d + " ");
- }
- Console.WriteLine("}");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement