#include "stdio.h"
#include "math.h"
#define ERROR -1
#define OK 0
int getAnswer(void)
{
double a,x;
double y;
scanf("Please input a = %f,x = %f",&a,&x);
/*這裏有些疑問,原方程中ex是不是e的x冥?*/
y = cos(a * x) + log(a + x) + exp(x);
printf("get the answer = %f",y);
}
int getRate(void)
{
/*請根據輸入或自行修改參數*/
double dblYear = 0,dblRate = 0;
int nBase = 0;
double dblInterest;
scanf("Please input the money = %.2f,and the rate = %.2f,the years = %.2f",&nBase,&dblRate,&dblYear);
dblInterest = nBase * (1 + dblRate) * dblYear - nBase;
printf("the Interest = %.2f",dblInterest);
return OK;
}
int getCapacity(void)
{
double P = 104;
double cosfai1 = 0.6;
double cosfai = 0.95;
double frequence = 50;
double U = 220;
double capacity;
double tanfai1,tanfai;
/*tanφ1 = sinφ1 / cosφ1 = sqrt(1 - cosφ1 * cosφ1) / cosφ1*/
double tmp;
/*采用這種形式是因為sqrt函數在輸入為負的情況下會出現定義域錯誤。*/
tmp = 1 - cosfai1 * cosfai1;
if(tmp < 0) return ERROR;
tanfai1 = sqrt(tmp) / cosfai1;
tmp = 1 - cosfai * cosfai;
if(tmp < 0) return ERROR;
tanfai = sqrt(tmp) / cosfai;
capacity = P * (tanfai1 - tanfai) / (2 * frequence * U);
return OK;
}