函数调用解析
2016-10-10 22:31
92 查看
程序中,主要在于调用函数和函数定义之间必须相互吻合!
/*****************************************************
copyright (C), 2014-2015, Lighting Studio. Co., Ltd.
File name:
Author:Jerey_Jobs Version:0.1 Date:
Description:
Funcion List:
*****************************************************/
#include <stdio.h>
#include <math.h>
float f(float x);
float xpoint(float x1,float x2);
float root(float x1,float x2);
int main()
{
float x1,x2,y1,y2,x,y;
do
{
printf("请输入两个x1和x2...\n");
scanf("%f,%f",&x1,&x2);
}while(f(x1)*f(x2)>=0);
x=root(x1,x2);
printf("答案是%f\n",x);
return 0;
}
float f(float x)
{
float y;
y=((x - 5.0)*x+16.0)*x - 80.0;
return y;
}
float xpoint(float x1,float x2)
{
float x;
x=(x1*f(x2)-x2*f(x1))/(f(x2)-f(x1));
return x;
}
float root(float x1,float x2)
{
float x,y,y1;
y1=f(x1);
do
{
x=xpoint(x1,x2);
y=f(x);
if(y*y1>0)
{
y1=y;
x1=x;
}
else
{
x2=x;
}
}while(fabs(y)>=0.000001);
return x;
}
/*****************************************************
copyright (C), 2014-2015, Lighting Studio. Co., Ltd.
File name:
Author:Jerey_Jobs Version:0.1 Date:
Description:
Funcion List:
*****************************************************/
#include <stdio.h>
#include <math.h>
float f(float x);
float xpoint(float x1,float x2);
float root(float x1,float x2);
int main()
{
float x1,x2,y1,y2,x,y;
do
{
printf("请输入两个x1和x2...\n");
scanf("%f,%f",&x1,&x2);
}while(f(x1)*f(x2)>=0);
x=root(x1,x2);
printf("答案是%f\n",x);
return 0;
}
float f(float x)
{
float y;
y=((x - 5.0)*x+16.0)*x - 80.0;
return y;
}
float xpoint(float x1,float x2)
{
float x;
x=(x1*f(x2)-x2*f(x1))/(f(x2)-f(x1));
return x;
}
float root(float x1,float x2)
{
float x,y,y1;
y1=f(x1);
do
{
x=xpoint(x1,x2);
y=f(x);
if(y*y1>0)
{
y1=y;
x1=x;
}
else
{
x2=x;
}
}while(fabs(y)>=0.000001);
return x;
}
相关文章推荐
- 函数调用约定解析
- Linux系统调用之sysinfo函数解析
- 利用java反射调用实现对字符串的解析,成功调入函数,并且返回值
- Cocos2dx通过JniHelper调用java函数,报错error link2019: 无法解析的外部命令
- 函数调用方式解析
- 函数调用约定解析 转载自:http://www.allaboutprogram.com
- 函数调用约定解析
- shell自定义函数及参数调用解析
- 函数调用约定解析
- vs2008中,静态库调用时报错:“无法解析的外部符号 _,该符号在函数 _wmain 中被引用”的解决方法
- 函数调用约定解析 汇编解析
- 函数调用方式解析
- 函数调用约定解析 汇编解析
- shell自定义函数及参数调用解析
- 线程实用解析--------(二)创建调用有参函数的线程和线程池简介
- 解析“进程、过程调用、函数调用、堆、栈”
- 解析“进程、过程调用、函数调用、堆、栈”
- 解决vc C++ 调用 C 函数时unresolved external symbol " __cdecl 。。。无法解析的外部符合
- c调用python函数时,解析其返回值
- 物理读,硬解析,函数调用在查询中耗时的大概分比