解方程
来源:互联网 发布:软件限制策略怎么打开 编辑:程序博客网 时间:2024/06/11 23:53
#include<stdio.h>
#include<math.h>
float x1,x2;
void sit1(float a,float b)
{
x1=x2=-b/(2.*a);
}
void sit2(float a,float b,float disc)
{
x1=(-b+sqrt(disc))/(2.*a);
x2=(-b-sqrt(disc))/(2.*a);
}
void sit3(float a,float b,float disc)
{
float realpart,imagepart;
realpart=-b/(2.*a);
imagepart=sqrt(-disc)/(2.*a);
x1=realpart+imagepart;
x2=realpart-imagepart;
}
void main()
{
float a,b,c,disc;
scanf("%f,%f,%f",&a,&b,&c);
printf("The equation ");
if(fabs(a)<=1e-6)
printf("is not a quadratic/n");
else
{
disc=b*b-4.*a*c;
if(fabs(disc)<=1e-6)
{
sit1(a,b);
printf("has two equal roots:%8.4f/n",x1);
}
else
if(disc>1e-6)
{
sit2(a,b,disc);
printf("has distinct real roots:%8.4f and %8.4f/n",x1,x2);
}
else
{
sit3(a,b,disc);
printf("has complex roots: /n");
printf("%8.4f/n",x1);
printf("%8.4f/n",x2);
}
}
}
- 解方程
- 解方程
- 解方程
- 解方程
- 解方程
- 解方程
- 解方程
- 解方程
- 解方程
- 解方程
- 解方程
- 解方程
- 解方程
- 解方程
- 解方程
- 波动方程,达朗贝尔解和亥姆霍兹方程
- matlab之自定义方程系数解方程
- 二分法解方程MATLAB
- tomcat 4.1.30启动过程的源码分析
- Debian Linux操作系统下本地源的安装方法
- Shader 学习笔记 ---Looking Through a Filter 过滤器
- 阴谋爱国者
- 好长时间没有更新技术blog了
- 解方程
- 自然辩证法题目(尚智丛老师)
- Excel中的OFFSET函数
- OpenText 方法
- 自然辩证法复习提纲(尚智丛老师)
- 靠你,倚着墙
- 链表
- 利用FileSystemObject对象来处理文件
- 利用API函数来处理文件