Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)
Paste
Pasted as C++ by Anonymous ( 16 years ago )
#include <iostream>
#include <math.h>
using namespace std;
#define square(x) (x)*(x)
#define cube(x) square(x)*(x)
//
void lab1_1() {
double b;
cout << "Введите b: ";
cin >> b;
cout << (9 - square(b + 2)) / (square(b) + 10*b + cube(25)) << endl;
}
//
void lab1_2() {
double x;
cout << "Введите x: ";
cin >> x;
if (x <= 0.0 || x == 1.0) {
cerr << "x не может быть меньше или равен 0 или равен 1." << endl;
return;
}
cout << (square(log(x)) / (1 + square(log(x))) + x / (log(x) - 1)) << endl;
}
//
double f(double x) {
if (x >= 8) {
return -square(x) + x - 9;
}
else {
return 1 / (pow(x, 4) - 6);
}
}
void lab2_1() {
double x;
cout << "Введите x: ";
cin >> x;
double sqrt_sqrt_6 = sqrt(sqrt(6));
if (fabs(x) >= (sqrt_sqrt_6 - 1.0e-30) && fabs(x) <= (sqrt_sqrt_6 + 1.0e-30)) {
cerr << "Модуль x не может быть равен корню четвертой степени из 6." << endl;
return;
}
cout << f(x) << endl;
}
//
void lab2_2() {
unsigned int N;
cout << "Введите N: ";
cin >> N;
if (N <= 99 && N >= 10 && N % 2 == 0) {
cout << "Да." << endl;
}
else {
cout << "Нет." << endl;
}
}
//
void lab2_3() {
double x;
cout << "Введите x: ";
cin >> x;
if (x <= 0.0) {
cout << "ln(x) не имеет смысла для такого x." << endl;
if (sin(x) <= cos(x)) {
cout << sin(x) << endl << cos(x) << endl;
}
else {
cout << cos(x) << endl << sin(x) << endl;
}
}
else {
// А тут я применил генератор кода. Вот какой я молодец. ^_^
if (sin(x) <= cos(x) && cos(x) <= log(x)) {
cout << sin(x) << endl << cos(x) << endl << log(x) << endl;
}
if (sin(x) <= log(x) && log(x) <= cos(x)) {
cout << sin(x) << endl << log(x) << endl << cos(x) << endl;
}
if (cos(x) <= sin(x) && sin(x) <= log(x)) {
cout << cos(x) << endl << sin(x) << endl << log(x) << endl;
}
if (cos(x) <= log(x) && log(x) <= sin(x)) {
cout << cos(x) << endl << log(x) << endl << sin(x) << endl;
}
if (log(x) <= sin(x) && sin(x) <= cos(x)) {
cout << log(x) << endl << sin(x) << endl << cos(x) << endl;
}
if (log(x) <= cos(x) && cos(x) <= sin(x)) {
cout << log(x) << endl << cos(x) << endl << sin(x) << endl;
}
}
}
int main(int argc, char **argv) {
lab2_3();
return 0;
}
Revise this Paste