Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- struct complex {
- float re;
- float im;
- };
- complex read() {
- complex c;
- cout << "Введите действительную часть: ";
- cin >> c.re;
- cout << "Введите мнимую часть: ";
- cin >> c.im;
- return c;
- }
- void print(complex c) {
- cout << "Действиетельная часть комплексного числа " << c.re << " и мнимамая " << c.im << "i";
- }
- complex add(complex a, complex b) {
- complex result;
- result.re = a.re + b.re;
- result.im = a.im + b.im;
- return result;
- }
- int main() {
- setlocale(LC_ALL, "Rus");
- complex num1, num2, sum;
- cout << "Введите первое комплексное число:" << endl;
- num1 = read();
- cout << "Введите второе комплексное число:" << endl;
- num2 = read();
- cout << "Сумма комплексных чисел:" << endl;
- sum = add(num1, num2);
- print(sum);
- }
Advertisement
Add Comment
Please, Sign In to add comment