KiszaBoss Posted January 16, 2012 Report Share Posted January 16, 2012 witam wszystkich. mam maly proble gdyż pisze teraz program geodezyjny i jest mi w pewnym wzorze potrzebna funkcja sinusa, cosinusa, tangens i cotangensa, niestety niewiem jak je uzyc w programie(jestem poczatkujacy) prosze o pomoc. jezeli bedzie taka potrzeba moge wstawic moj programik. pozdrawiam Link to comment Share on other sites More sharing options...
Jason Posted January 16, 2012 Report Share Posted January 16, 2012 include'ujesz math.h, albo cmath i używasz funkcji. Funkcje trygonometryczne z math pobierają argument w radianach, więc pewnie przyda Ci się napisać funkcję zamieniającą stopnie na radiany. Link to comment Share on other sites More sharing options...
KiszaBoss Posted January 17, 2012 Author Report Share Posted January 17, 2012 a mozesz mi podać to na jakims przykladzie Link to comment Share on other sites More sharing options...
Jason Posted January 17, 2012 Report Share Posted January 17, 2012 #include "stdio.h" #include "math.h" double DegToRad(double a) { return ((a*M_PI)/180.0); }; double RadToDeg(double a) { return ((180.0*a)/M_PI); }; int main() { double kat=DegToRad(30.0); // kat 30 stopni, w radianach printf("kat=%lf, sin=%lf, cos=%lf, tan=%lf",RadToDeg(kat),sin(kat),cos(kat),tan(kat)); return 0; } //jak dawałem code C, to nie wypisywało tego jak należy :/ W GCC musisz dopisać w opcjach linkera -lm Linia kompilacji by wyglądała o tak: gcc -Wall -lm -o main.exe main.c W przeciwnym razie wyrzuca undeclared reference. - http://joysofprogram...ference-to-cos/ Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.