#include <iostream>
#include <conio.h> // библиотека, необходимая для работы оператора getch();
#include <cmath>
#define PI 3.14159265 // число ПИ
class Geometry
{
private:
double _angle; // угол в градусах
public:
// конструктор
Geometry(double angle) { _angle = angle * PI / 180; } // переведённого в радианы
// деструктор
~Geometry(){}
// получение угла
double GetAngle() { return _angle; }
// синус угла
double GetAngleSine();
// косинус угла
double GetAngleCosine();
// тангенс угла
double GetAngleTangent();
// котангенс угла
double GetAngleCotangent();
// вывод табоицы
void Text(double angle);
};
double Geometry::GetAngleSine()
{
return sin(_angle);
}
double Geometry::GetAngleCosine()
{
return cos(_angle);
}
double Geometry::GetAngleTangent()
{
return tan(_angle);
}
double Geometry::GetAngleCotangent()
{
return 1 / tan(_angle);
}
void Geometry::Text(double angle)
{
std::cout << " angle \t sine \t cosine \t tangent \t cotangent" << std::endl;
std::cout << angle << (char)DEGREES << " \t " << GetAngleSine() << "\t " << GetAngleCosine() << "\t " << GetAngleTangent() << "\t " << GetAngleCotangent() << std::endl;
}
int main()
{
double angle;
std::cout << "Input angle in degrees: ";
std::cin >> angle;
Geometry g = Geometry(angle);
g.Text(angle);
getch();
return 0;
}
Input angle in degrees: 30
angle sine cosine tangent cotangent
30° 0.5 0.866025 0.57735 1.73205
#include <iostream>
#include <conio.h> // библиотека, необходимая для работы оператора getch();
#include <cmath> // библиотека математики
#define PI 3.14159265 // число ПИ
class Geometry
{
private:
double _angle; // угол в градусах
public:
// конструктор
Geometry(double angle) { _angle = angle * PI / 180; } // переведённого в радианы
// деструктор
~Geometry(){}
// получение угла
double GetAngle() { return _angle; }
// синус угла
double GetAngleSine();
// косинус угла
double GetAngleCosine();
// тангенс угла
double GetAngleTangent();
// котангенс угла
double GetAngleCotangent();
// вывод табоицы
void Text(double angle);
};
double Geometry::GetAngleSine()
{
return sin(_angle);
}
double Geometry::GetAngleCosine()
{
return cos(_angle);
}
double Geometry::GetAngleTangent()
{
return tan(_angle);
}
double Geometry::GetAngleCotangent()
{
return 1 / tan(_angle);
}
void Geometry::Text(double angle)
{
std::cout << " angle \t sine \t cosine \t tangent \t cotangent" << std::endl;
std::cout << angle << (char)DEGREES << " \t " << GetAngleSine() << "\t " << GetAngleCosine() << "\t " << GetAngleTangent() << "\t " << GetAngleCotangent() << std::endl;
}
int main()
{
double angle;
std::cout << "Input angle in degrees: ";
std::cin >> angle;
Geometry g = Geometry(angle);
g.Text(angle);
getch();
return 0;
}
Input angle in degrees: 30
angle sine cosine tangent cotangent
30° 0.5 0.866025 0.57735 1.73205
Если Вы уже зарегистрированы на Портале - войдите в систему, если Вы еще не регистрировались - пройдите простую процедуру регистрации.