This commit is contained in:
ada-dmitry
2023-11-21 23:00:20 +03:00
parent 54e7270fb8
commit 8111104a39
3 changed files with 16 additions and 10 deletions
+15
View File
@@ -1,5 +1,6 @@
#include <stdio.h>
#include <signal.h>
#include <unistd.h>
double f(double x); // function x
void find_zero(double *pa, double *pb, double eps, double *px); //
@@ -11,13 +12,27 @@ int main()
{
double a, b, eps, x, *pa = &a, *pb = &b, *px = &x;
char choice = ' ', *ch = &choice;
sigset_t set;
int sig;
printf("Введите интервал [a, b] и точность eps: ");
scanf("%lf %lf %lf", pa, pb, &eps);
// if (a > b || )
find_zero(pa, pb, eps, px);
// Создание набора сигналов и добавление в него SIGINT
sigemptyset(&set);
sigaddset(&set, SIGINT);
// Блокировка SIGINT
sigprocmask(SIG_BLOCK, &set, NULL);
// Ожидание получения сигнала Ctrl+C с помощью sigwait
sigwait(&set, &sig);
signal(SIGINT, ctrlc_handler);
printf("Корень уравнения: %lf\n", *px);
printf("Работа программы завершена.\n");