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 ConsoleApp1
- {
- class Program
- {
- static void Main(string[] args)
- {
- Console.WriteLine("Введите комплексные числа: ");
- Console.WriteLine("Введите комплексное число 1: ");
- double a1 = Convert.ToDouble(Console.ReadLine());
- double b1 = Convert.ToDouble(Console.ReadLine());
- Console.WriteLine("Введите комплексное число 2: ");
- double a2 = Convert.ToDouble(Console.ReadLine());
- double b2 = Convert.ToDouble(Console.ReadLine());
- Console.WriteLine("Выберите действие: ");
- int change = Convert.ToInt32(Console.ReadLine());
- Console.WriteLine(ComplexNumb(a1, b1, a2, b2, change)[0] + "; " + ComplexNumb(a1, b1, a2, b2, change)[1] + "i");
- Console.ReadKey();
- }
- public static double[] ComplexNumb(double a1, double b1, double a2, double b2, int vibor)
- {
- double[] temp = new double[2];
- switch (vibor)
- {
- case 1:
- temp[0] = a1 + a2;
- temp[1] = b1 + b2;
- break;
- case 2:
- temp[0] = a1 - a2;
- temp[1] = b1 - b2;
- break;
- case 3:
- temp[0] = a1 * a2 - b1 * b2;
- temp[1] = a1 * b2 + a2 * b1;
- break;
- case 4:
- temp[0] = (a1 * a2 + b1 * b2) / (a2 * a2 + b2 * b2);
- temp[1] = (a2 * b1 - a1* b2) / (a2 * a2 + b2 * b2);
- break;
- }
- return temp;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement