import math
import sys
#Задача 1
print("Програма, яка визначає квадратний корінь числа")
a = int(input("Введіть ціле число: "))
if a == 0:
sys.exit(0)
b = math.sqrt(a)
print("Квадратний корінь з числа", a, "дорівнює", b)
#Задача 2
print("\nПрограма, яка визначає площу круга")
c = int(input("Введіть дійсне число - радіус кола: "))
if c == 0:
sys.exit(0)
d = math.pi*c**2
print("Площа круга дорівнює", d)
#Задача 7
print("\nПрограма, яка визначає площу круга")
c = int(input("Введіть дійсне число - діаметр кола: "))
if c == 0:
sys.exit(0)
d = math.pow(c, 2) // 4 * math.pi
print("Площа круга дорівнює", d)
#Задача 8
print("\nПрограма, яка обчислює довжину гіпотенузи прямокутного трикутника")
c1 = int(input("Введіть перший катет: "))
c2 = int(input("Введіть другий катет: "))
if c1 == 0 or c2 == 0:
sys.exit(0)
h = math.hypot(c1, c2)
print("Довжина гіпотенузи прямокутного трикутника дорівнює", h)
Объяснение:
/ deit.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
#include <iomanip>
#include <math.h>
#include <locale>
using namespace std;
void vvod_matr(int mas[][4], const int &n, const int &m)
{
for(int i = 0; i < n; i++)
for(int j = 0; j < m; j++)
{
wcout << L"Введите элемент матрицы[" << i << "][" << j << "]: ";
cin >> mas[i][j];
}
}
void print(int mas[][4], const int &n, const int &m)
{
for(int i = 0; i < n; i++)
{
cout << "\n\t";
for(int j = 0; j < m; j++)
{
cout << setw(3) << setiosflags(ios::left) << mas[i][j];
}
}
}
void _tmain()
{
wcout.imbue(locale(".866"));
const int n = 4, m = 4;
int mas[n][m];
wcout << L"Введите матрицу:\n";
vvod_matr(mas, n, m);
wcout << L"\nВведенная матрица:\n";
print(mas, n, m);
/* умножаем четные элементы матрицы*/
int prois_chet = 1;
for(int i = 0; i < n; i++)
for(int j = 0; j < m; j += 2)
{
prois_chet *= mas[i][j];
}
wcout << L"\n\nПроизведение четных элементов матрицы: " << prois_chet;
/*упорядочиваем элементы второго столбца по возрастанию*/
int stb = 1, t;
for(int i = 0; i < n-1; i++)
for(int j = i+1; j < n; j++)
{
if(mas[i][stb] < mas[j][stb])
{
t = mas[i][stb];
mas[i][stb] = mas[j][stb];
mas[j][stb] = t;
}
}
wcout << L"\n\nУпрядоченная матрица:\n";
print(mas, n, m);
cout << "\n\n";
}
Объяснение:
программа большая 74 строчки поэтому сайт может не так её отобразить