Z
Z
zhqrik2019-04-14 15:11:02
C++ / C#
zhqrik, 2019-04-14 15:11:02

What is the error, why does it give a compilation error?

#include <iostream>
#include <cmath> //нужно для pow()
#include <utility>
#include <functional>
using namespace std;
int main()
{

double z,a,b,y,c,d;
cout <<"Введите вещественную и мнимую части числа z"<<endl;
cin>> a>> b;
cout <<"Введите вещественную и мнимую части числа y"<<endl;
cin>> c >> d ;
z = make_pair (a,b);
y = make_pair (c,d);
if(z == y) {
  cout << "Модуль равна " << pow(pow(z.first,2)+pow(y.second,2),0.5);
}
else {
  cout <<"Мнимая часть y= " << y.second;
}
}

Answer the question

In order to leave comments, you need to log in

2 answer(s)
N
Nikita, 2019-04-14
@zhqrik

pair <double, double> z = make_pair(a, b);
pair <double, double> y = make_pair(c, d);

V
Vitaly, 2019-04-14
@vt4a2h

Usually the compiler writes why it cannot compile. Read and fix.
Here you have the wrong type for the variables "z" and "y".

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question