#include <stdio.h>
#include <math.h>
#define SIZE 100
void transform(double sr[],double tr[],int n,double (*pf)(double));
void show_arr(double tr[],int n);
double get_half(double sr);
double add_self(double sr);
int main(void)
{
double tr[SIZE];
double sr[SIZE];
double (*pf)(double);
pf=fabs;
for(int i=0;i<SIZE;i++)
{
sr[i]=i;
}
transform(sr,tr,SIZE,pf);
show_arr(tr,SIZE);
pf=sin;
transform(sr,tr,SIZE,pf);
show_arr(tr,SIZE);
pf =get_half;
transform(sr,tr,SIZE,pf);
show_arr(tr,SIZE);
pf =add_self;
transform(sr,tr,SIZE,pf);
show_arr(tr,SIZE);
return 0;
}
void transform(double sr[],double tr[],int n,double (*pf)(double))
{
for(int i=0;i<n;i++)
{
tr[i]=pf(sr[i]);
}
}
void show_arr(double tr[],int n)
{
for(int i=0;i<n;i++)
{
printf("AR[%d] %lf\n",i,tr[i]);
}
}
double get_half(double sr)
{
double result;
result = sr/2.0;
return result;
}
double add_self(double sr)
{
double result;
result = sr+sr;
return result;
}