Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- struct complex
- {
- int real; //действительная часть
- int image; //мнимая часть
- };
- int add(int x, int y)
- {
- int rez = x + y;
- return rez;
- }
- complex add(complex x, complex y)
- {
- complex rez;
- rez.real = x.real + y.real;
- rez.image = x.image + y.image;
- return rez;
- }
- void main()
- {
- setlocale(LC_ALL, "russian"); // чтобы на консоли отображались русские буквы
- int r1, r2;
- cout << "Целое число №1: ";
- cin >> r1;
- cout << "Целое число №2: ";
- cin >> r2;
- cout << endl;
- complex c1, c2;
- cout << "---Комплексное число №1: " << endl;
- cout << "Действительная часть: ";
- cin >> c1.real;
- cout << "Мнимая часть: ";
- cin >> c1.image;
- cout << "---Комплексное число №2: " << endl;
- cout << "Действительная часть: ";
- cin >> c2.real;
- cout << "Мнимая часть: ";
- cin >> c2.image;
- cout << endl;
- int rez1 = add(r1, r2);
- cout << "Сложение целых чисел: " << r1 << " + " << r2 << " = " << rez1 << endl;
- cout << "Сложение комплексных чисел:" << endl;
- complex rez2 = add(c1, c2);
- cout << "(" << c1.real << " + " << c1.image << "i) + (" << c2.real << " + " << c2.image << "i) = " << rez2.real << " + " << rez.image << "i" << endl;
- system("pause"); // чтобы после выполнения программы консоль не исчезала сразу же
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement