下面是用函数指针
实现的三角函数表,其中cos函数、sin函数和tan函数都已经在<math.h>
中定义,函数tabulate
中使用的函数ceil
也属于<math.h>
,当给定double
型实参x时,函数ceil
会返回大于或等于x的最小整数。当给定三角函数的起始值,终止值和步长以后,程序会打印出相对应的三角函数值。
#include <math.h>
#include <stdio.h>
// 传递函数指针f时,tabulate函数显示函数f的值
void tabulate(double (*f)(double), double first, double last, double incr);
int main(void)
{
double initial, final, increment;