Zadání:
Sestavte knihovnu, která bude obsahovat goniometrické funkce nedefinované v jazyce C. Tuto knihovnu použijte ve vlastním programu.
#include "stdafx.h"
#include "gonfce.h"
#include
int _tmain(int argc, _TCHAR* argv[])
{
float x,y;
char z;
printf("Zadejte hodnotu: ");
scanf_s("%f",&x,1);
printf("-----------------------------------\n");
printf("1 sinus\n");
printf("2 cosinus\n");
printf("3 tangens\n");
printf("4 cotangens\n");
printf("5 arcussinus\n");
printf("6 arcuscosinus\n");
printf("7 arcustangens\n");
printf("8 arcuscotangens\n");
printf("-----------------------------------\n");
printf("Zadejte funkci: ");
scanf_s("\n%c",&z,1);
switch (z)
{
case '1':
y=sin(x);
printf("sin(%.3f)=%.3f\n",x,y);
break;
case '2':
y=cos(x);
printf("cos(%.3f)=%.3f\n",x,y);
break;
case '3':
y=tan(x);
printf("tg(%.3f)=%.3f\n",x,y);
break;
case '4':
y=cotg(x);
printf("cotg(%.3f)=%.3f\n",x,y);
break;
case '5':
y=asin(x);
printf("arcsin(%.3f)=%.3f\n",x,y);
break;
case '6':
y=acos(x);
printf("arccos(%.3f)=%.3f\n",x,y);
break;
case '7':
y=atan(x);
printf("arctg(%.3f)=%.3f\n",x,y);
break;
case '8':
y=arccotg(x);
printf("arccotg(%.3f)=%.3f\n",x,y);
break;
default:
printf("Neznama funkce\n");
}
system("pause");
return 0;
}
#include "stdafx.h"
#include
#include "math.h"
float cotg(float x);
float arccotg(float x);
#include "stdafx.h"
#include
#include "math.h"
float cotg(float x)
{
float c=cos(x)/sin(x);
return c;
}
float arccotg(float x)
{
const float pi=3.1415926;
float c=pi/2-atan(x);
return c;
}
program ke stažení