| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 623 人关注过本帖
标题:[求助]大家帮我看看,为什么这个程序不能执行
只看楼主 加入收藏
梦幻之人
Rank: 1
等 级:新手上路
帖 子:18
专家分:0
注 册:2005-5-13
收藏
 问题点数:0 回复次数:4 
[求助]大家帮我看看,为什么这个程序不能执行

大家好,有个程序其代码如下:

#include <math.h> float x1,x2,disc,p,q; greater_than_zero(float a,float b) {x1=(-b+sqrt(disc))/(2*a); x2=(-b-sqrt(disc))/(2*a); } equal_than_zero(float a,float b) { x1=x2=(-b)/(2*a); } smaller_than_zero(float a,float b) { p=(-b)/(2*a>; q=sqrt(disc)/(2*a); } main() { float a,b,c; printf("\nInput a,b,c:"); scanf("%f,%f,%f",&a,&b,&c); printf("\nequation:%5.2f*x*x+%5.2f*x+%5.2f=0\n",a,b,c); disc=b*b-4*a*c; printf("root:\n"); if (disc>0) { greater_than_zero(a,b); printf("x1=%5.2f\tx2=%5.2f\n\n",x1,x2); } else if (disc=0) {equal_than_zero(a,b); printf("x1=%5.2f\tx2=%5.2f\n\n",x1,x2); } else {smaller_than_zero(a,b); printf("x1=%5.2f+%5.2fi\tx2=%5.2f-%5.2fi\n",p,q,p,q); } }

为什么最后在运行的时候会出现如图的提示啊,请高手教教我,不胜感激!!!

谢谢大家!!

搜索更多相关主题的帖子: float disc zero 
2005-06-04 09:03
梦幻之人
Rank: 1
等 级:新手上路
帖 子:18
专家分:0
注 册:2005-5-13
收藏
得分:0 
图:
#include &lt;math.h&gt;
float x1,x2,disc,p,q;
greater_than_zero(float a,float b)
{x1=(-b+sqrt(disc))/(2*a);
x2=(-b-sqrt(disc))/(2*a);
}
equal_than_zero(float a,float b)
{
x1=x2=(-b)/(2*a);
}
smaller_than_zero(float a,float b)
{
p=(-b)/(2*a&gt;;
q=sqrt(disc)/(2*a);
}
main()
{
float a,b,c;
printf("\nInput a,b,c:");
scanf("%f,%f,%f",&amp;a,&amp;b,&amp;c);
printf("\nequation:%5.2f*x*x+%5.2f*x+%5.2f=0\n",a,b,c);
disc=b*b-4*a*c;
printf("root:\n");
if (disc&gt;0)
{
greater_than_zero(a,b);
printf("x1=%5.2f\tx2=%5.2f\n\n",x1,x2);
}
else if (disc=0)
  {equal_than_zero(a,b);
  printf("x1=%5.2f\tx2=%5.2f\n\n",x1,x2);
  }
  else
  {smaller_than_zero(a,b);
  printf("x1=%5.2f+%5.2fi\tx2=%5.2f-%5.2fi\n",p,q,p,q);
  }
}
2005-06-04 09:06
梦幻之人
Rank: 1
等 级:新手上路
帖 子:18
专家分:0
注 册:2005-5-13
收藏
得分:0 
图开如下:
图片附件: 游客没有浏览图片的权限,请 登录注册
2005-06-04 09:07
牛虻
Rank: 1
等 级:新手上路
威 望:1
帖 子:472
专家分:0
注 册:2004-10-1
收藏
得分:0 
功能函数smaller_than_zero有语法错误

土冒
2005-06-04 09:46
牛虻
Rank: 1
等 级:新手上路
威 望:1
帖 子:472
专家分:0
注 册:2004-10-1
收藏
得分:0 
以下是引用梦幻之人在2005-6-4 9:06:13的发言: #include <math.h> float x1,x2,disc,p,q; greater_than_zero(float a,float b) {x1=(-b+sqrt(disc))/(2*a); x2=(-b-sqrt(disc))/(2*a); } equal_than_zero(float a,float b) { x1=x2=(-b)/(2*a); } smaller_than_zero(float a,float b) { p=(-b)/(2*a>; //改成p=(-b)/(2*a); q=sqrt(disc)/(2*a); } main() { float a,b,c; printf("\nInput a,b,c:"); scanf("%f,%f,%f",&a,&b,&c); printf("\nequation:%5.2f*x*x+%5.2f*x+%5.2f=0\n",a,b,c); disc=b*b-4*a*c; printf("root:\n"); if (disc>0) { greater_than_zero(a,b); printf("x1=%5.2f\tx2=%5.2f\n\n",x1,x2); } else if (disc=0) {equal_than_zero(a,b); printf("x1=%5.2f\tx2=%5.2f\n\n",x1,x2); } else {smaller_than_zero(a,b); printf("x1=%5.2f+%5.2fi\tx2=%5.2f-%5.2fi\n",p,q,p,q); } }

土冒
2005-06-04 09:49
快速回复:[求助]大家帮我看看,为什么这个程序不能执行
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.015364 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved