artem05kz / Prosedyrka_HW

0 stars 0 forks source link

ДОМАШНЕЕ ЗАДАНИЕ № 1 #1

Open artem05kz opened 1 year ago

artem05kz commented 1 year ago

ДОМАШНЕЕ ЗАДАНИЕ № 1 Задание «Имя».

include

int main() { printf("artem"); }

Задание «Арифметика»

include

include

using namespace std; int main() { double a, b; cout << "vvedite a \n"; cin>> a; cout << "vvedite b \n"; cin>> b; cout << a+b << endl << a-b << endl << a*b << endl << endl; if (b == 0) { cout<< "NA 0 ne delitsa"; } else { cout<< a/b; } }

Задание «Уравнение».

include

using namespace std; int main() {
double b, c, x; cout << "Vvedite chislo b\n"; cin >> b; cout << "Vvedite chislo c\n"; cin >> c; if(b==0) { cout<<"Na 0 del nelza"; } else
{ x = (-c)/b; cout << "x = " << x; } }

Задание «Еще уравнение».

include

include

using namespace std; int main() { setlocale(LC_ALL, "Russian"); double a, b, c; cout << "Введите коэффициенты a, b и c квадратного уравнения ax^2 + bx + c = 0:" << endl; cin >> a >> b >> c; double d = b b - (4 a * c);

if (d > 0) {

     if (a == 0) {
        if ((b == 0) && (c == 0)) {
            cout << "x: любое число" << endl;
        }
        else if ((b != 0) && (c == 0)) {
            cout << "x: 0" << endl;
        }
        else if ((b == 0) && (c != 0)){
            cout << "нет решений" << endl;
        }
        else {
            cout << "x: " << ((0 - c) / b) << endl;
        }
    }

    else if (b == 0) {
        if ((a == 0) && (c == 0)) {
            cout << "x: любое число" << endl;
        }
        else if ((a != 0) && (c == 0)) {
            cout << "x: 0" << endl;
        }
        else if ((a == 0) && (c != 0)) {
            cout << "нет решений" << endl;
        }
        else {
            cout << "x:1 " << -1 * sqrt((0 - c) / a) << endl << "x2: " << sqrt((0 - c) / a) << endl;
        }
    }

    else  if (c == 0) {
        if ((a == 0) && (b == 0)) {
            cout << "x: любое число" << endl;
        }
        else if ((a != 0) && (b == 0)) {
            cout << "x: 0" << endl;
        }
        else if ((a == 0) && (b != 0)) {
            cout << "x: 0" << endl;
        }
        else {
            cout << "x1: 0" << endl << "x2: " << b / a << endl;
        }
    }
    else {
        cout << "x1: " << ( ( (-1 * b) + (sqrt(d) ) ) / (2 * a) ) << endl << "x2: " << (((-1 * b) - sqrt(d)) / (2 * a)) << endl;
    }
}
else if (d == 0) {
    if ((a == 0) && (b == 0) && (c == 0)) {
        cout << "x : любое число" << endl;
    }
    else {
        cout << "x: " << (-1 * b) / (2 * a) << endl;
    }
}
else if (d < 0) {
    cout << "дискриминант меньше нуля" << endl;
}

}

Задание «Лампа со шторой».

include

include

using namespace std;

include

int main(){

bool day, shori, lampa;
cout << "lampa rabotaet? 0-net 1-da \n";
cin >> lampa;
cout << "na ylize day? 0-net 1-da \n";
cin >> day;
cout <<"shori otkriti? 0-net 1-da \n";
cin >> shori;

if(lampa == true){
    cout<<"V komnate svetlo";}
else if(day && shori == true){
    cout<<"V komnate svetlo";}
else{
    cout<<"V komnate temno";}

}