Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include "math.h"
- double sin1(double x, bool &ok)
- {
- ok = true;
- return sin(x);
- }
- double tg1(double x, bool &ok)
- {
- if (cos(x) == 0) ok = false;
- else ok = true;
- return sin(x) / cos(x);
- }
- double arcsinx(double x, bool &ok)
- {
- if (x>-1 && x<1) ok = false;
- else ok = true;
- return asin(x);
- }
- double pierw(double x, bool &ok)
- {
- if (x < 0) ok=false;
- else ok = true;
- return sqrt(x);
- }
- double logn(double x, bool &ok)
- {
- if (x <= 0) ok = false;
- else ok = true;
- return log(x);
- }
- int main()
- {
- char pol;
- double x,wynik;
- bool ok;
- int opcja;
- double(*tab[])(double, bool &) = { sin1,tg1,arcsinx,pierw,logn };
- while ()
- {
- printf_s("Podaj polecenie: ");
- scanf_s("%c", &pol,1);
- if (pol == 'n')
- {
- printf_s("Podaj liczbe: ");
- scanf_s("%lf", &x);
- }
- if (pol == 'f')
- {
- printf_s("Podaj opcje: ");
- scanf_s("%d", &opcja);
- wynik = tab[opcja](x, ok);
- if (ok)
- printf_s("%lf", wynik);
- else printf_s("bledny argument");
- }
- if (pol == 'q')
- {
- return 0;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement