oafanasiev41
?>

Напишите программу которая подсчитывает площадь квадрата на языке питон

Информатика

Ответы

Tatyanaaarzieva72

#include <iostream>

#include <vector>

using namespace std;

int f(vector<int> &u){

   int k = 1;

   bool has_negative = false;

   for(auto &i : u){

       if(i < 0){

           k *= i;

           has_negative = true;

       }

   }

   return k * has_negative;

}

signed main(){

   const int n = 5;

   vector<vector<int>> a(n, vector<int> (n));

   for(int i = 0; i < n; i++)

       for(int j = 0; j < n; j++)

           cin >> a[i][j];

   for(int i = 0; i < n; i++)

       cout << "Product of negatives in " << i + 1 << " line is " << f(a[i]) << "\n";

}

polina25258

Вариант 1:

using namespace std;

#include <iostream>

#include <clocale>

#include <cstdlib>

#include <iomanip>

#include <string>

int main() {

setlocale(LC_ALL, "rus");

system("chcp 1251");

srand(time(0));

double x;

cout << "Введите значение x" << endl;

cin >> x;

if (x <= 0)

 cout << pow(x, 4) << endl;

if (x > 0)

 cout << log10(x) << endl;

system("pause");

return 0;

}

Вариант 2:

using namespace std;

#include <iostream>

#include <clocale>

#include <cstdlib>

#include <iomanip>

#include <string>

int main() {

setlocale(LC_ALL, "rus");

system("chcp 1251");

srand(time(0));

double x;

cout << "Введите значение x" << endl;

cin >> x;

if (x >= 2)

 cout << sqrt(x) << endl;

if (x < 2)

 cout << log(3 - x) << endl;

system("pause");

return 0;

}

Ответить на вопрос

Поделитесь своими знаниями, ответьте на вопрос:

Напишите программу которая подсчитывает площадь квадрата на языке питон
Ваше имя (никнейм)*
Email*
Комментарий*