需要编译这个(试图找到二分的根) [英] need to compile this ( trying to find roots of a bisection)

查看:58
本文介绍了需要编译这个(试图找到二分的根)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

*************** *** ********************************************* *** *******


#include< stdio.h>

#include< conio.h>

#include< math.h>


void main()

{

double a,b,c,fa ,fb,fc,err;

int count;

clrscr();

printf(" \ n输入%lf的值) ;,a);

scanf("%lf"& a);

printf(\ n输入%lf的值,b) ;

scanf("%lf"& b);

err = exp(-6);

printf(" \\ n%lf",err);

while(fabs(ab)< = err)

{

fa = 2-(3 * sin(a)* exp(a));

printf(\ n%lf的值,fa);

fb = 2-(3 * sin(b)* exp(b));

printf(\ n%lf的值,fb);

c =(a + b)/ 2;

fc =(fa + fb)/ 2;

如果(fa!= 0)

{

If((fa> 0)&&(fb& gt; 0))

a = c;

else

b = c;

}

否则

{

printf(\ n fa的值不存在,继续使用fb);

}


如果(fb!= 0)

{

If(fb> 0)

如果(fc> 0)

b = c;

其他

a = c;

}

否则

{

printf(" \\\
fa,fb不存在,无法继续) );

}

count ++

}

printf(" \ n%lf"的值) ,a);

printf(\ n%lf的值,b);

printf(" \ n%d的值) ,数);

}


************************* ************************* ************************* ************************* ******

************************************************** ************************************************** *******

#include<stdio.h>
#include<conio.h>
#include<math.h>

void main()
{
double a,b,c,fa,fb,fc,err;
int count;
clrscr();
printf("\n enter value for %lf",a);
scanf("%lf",&a);
printf("\n enter value for %lf",b);
scanf("%lf",&b);
err = exp(-6);
printf("\n value of %lf",err);
while(fabs(a-b)<=err)
{
fa=2-(3*sin(a)*exp(a));
printf("\n the value of %lf",fa);
fb=2-(3*sin(b)*exp(b));
printf("\n the value of %lf",fb);
c=(a+b)/2;
fc=(fa+fb)/2;
If (fa!=0)
{
If ((fa>0)&&(fb>0))
a = c;
else
b = c;
}
Else
{
printf("\n the value of fa does not exist, proceed with fb");
}

If (fb != 0)
{
If (fb > 0)
If (fc > 0)
b = c;
else
a = c;
}
Else
{
printf ("\n fa,fb do not exist, cannot proceed");
}
count++
}
printf("\n the value of %lf",a);
printf("\n the value of %lf",b);
printf("\n the value of %d",count);
}

************************************************** ************************************************** ******

推荐答案

anand schrieb:
anand schrieb:
********************************* ***************** ********************************* ***************** *******
请在消息文本中说明您的问题。

BTW:" ;需要编译这个(试图找到二分的根)

不是很有帮助。

#include< stdio.h> ;
#include< conio.h>


这不是标准的C标题,所以我会忽略它并且

所有在其中一个没有原型的函数

包括标题。

#include< math.h>

void main()


这是错误的类型for main()。

写下

int main(无效)



int main(int argc ,char ** argv)

阅读
http://c-faq.com/ansi/index.html

问题11.12a至11.15 {
双a,b,c,fa,fb,fc ,错误;
int count;
clrscr();


未知功能。

printf(\ n输入%lf的值,a);


在C89中,在printf()中使用%lf会导致未定义的行为。
http://c-faq.com/stdio/scanfvsprintf.html

即使您使用%f,%e, %g,你仍然传递一个

未初始化的变量作为参数。

所以你可以用各种可能的方式运气。你的程序已经死了。

scanf("%lf",& a);


注意:1)如果你想要打印出前面的printf(),

要么通过''\ n''终止它,要么使用fflush(stdout) - 否则,

输出提示可能会在输入后显示它应该在
之前。

2)scanf()对于交互式输入来说并不是很好。

阅读comp.lang.c常见问题解答:
http://c-faq.com/stdio/scanfhang.html
http://c-faq.com/stdio/scanfinterlace.html

printf(" \\ \\ n输入%lf",b)的值;
scanf("%lf",& b);


dito。

err = exp(-6);
printf(%lf的\ n值,错误);
while(fabs(ab)< = err)
{
fa = 2-(3 * sin(a)* exp(a));
printf(" \ n%lf",fa)的值;
fb = 2-(3 * sin(b)* exp(b));
printf(&%;%的值) lf",fb);
c =(a + b)/ 2;
fc =(fa + fb)/ 2;
如果(fa!= 0)


在这里你甚至不再尝试了。

C是一种区分大小写的语言,因此你必须使用if,b来保持

;否则,...... {
如果((> 0)&&(fb> 0))
a = c;
其他
b = c;
}
其他
{/> printf(&\\'\\ fa的值不存在,继续使用fb);
}

如果(fb!= 0)
{
如果(fb> 0)
如果(fc> 0)
b = c;
else
a = c;
}
其他
{
printf(" \\\
fa,fb不存在,可以不要继续);
}
计数++
}
printf(" \ n%lf"的值,a);
printf(" \\ \\ n%lf",b)的值;
printf(" \ n%d的值,计数);


返回0; }
************************************************** ************************************************** ******* Please state your problem in the message text, too.
BTW: "need to compile this ( trying to find roots of a bisection)"
is not very helpful.
#include<stdio.h>
#include<conio.h>
This is not a standard C header, so I will ignore it and
all functions which have no prototype in one of the other
included headers.
#include<math.h>

void main()
This is the wrong type for main().
Write either
int main (void)
or
int main (int argc, char **argv)
Read
http://c-faq.com/ansi/index.html
Question 11.12a through 11.15 {
double a,b,c,fa,fb,fc,err;
int count;
clrscr();
Unknown function.
printf("\n enter value for %lf",a);
In C89, using %lf in printf() leads to undefined behaviour.
http://c-faq.com/stdio/scanfvsprintf.html
Even if you used %f, %e, %g, you still are passing an
uninitialized variable as argument.
So you luck out in every possible way. Your program is already
dead.
scanf("%lf",&a);
Note: 1)If you want the preceding printf() to be printed out,
either terminate it by ''\n'' or use fflush(stdout) -- otherwise,
the output prompt might show up after the input it should
precede.
2) scanf() is not really good for interactive input.
Read the comp.lang.c FAQ on this:
http://c-faq.com/stdio/scanfhang.html
http://c-faq.com/stdio/scanfinterlace.html
printf("\n enter value for %lf",b);
scanf("%lf",&b);
dito.
err = exp(-6);
printf("\n value of %lf",err);
while(fabs(a-b)<=err)
{
fa=2-(3*sin(a)*exp(a));
printf("\n the value of %lf",fa);
fb=2-(3*sin(b)*exp(b));
printf("\n the value of %lf",fb);
c=(a+b)/2;
fc=(fa+fb)/2;
If (fa!=0)
Here you are not even trying anymore.
C is a case sensitive language, so you have to stay
with "if", "else", ... {
If ((fa>0)&&(fb>0))
a = c;
else
b = c;
}
Else
{
printf("\n the value of fa does not exist, proceed with fb");
}

If (fb != 0)
{
If (fb > 0)
If (fc > 0)
b = c;
else
a = c;
}
Else
{
printf ("\n fa,fb do not exist, cannot proceed");
}
count++
}
printf("\n the value of %lf",a);
printf("\n the value of %lf",b);
printf("\n the value of %d",count);
return 0; }




我没有查看算法或循环内容。

首先修复上述内容并描述其他问题。


阅读整个comp.lang.c常见问题解答可以帮助您避免其他

错误。

干杯

Michael

-

电子邮件:我的是/ at / gmx / dot / de地址。



I did not look at the algorithm or at the loop contents.
Fix the above first and describe further problems.

Reading the whole comp.lang.c FAQ may help you avoid other
errors.
Cheers
Michael
--
E-Mail: Mine is an /at/ gmx /dot/ de address.


anand在主题专栏中写道需要编译这个(试图找到b / b
的根)其次是文盲垃圾声称是C

[mercifully snipped]。


不,你需要

1)打开你的C文本到第1页并重新开始并且

2)学会不将帖子的重要部分放在标题中,其中很多人会忽略它。
anand wrote in the subject line "need to compile this ( trying to find
roots of a bisection)" followed by illiterate garbage claiming to be C
[mercifully snipped].

No, you need
1) To open your C text to page 1 and start over and
2) learn to not put an important part of your post in the headers, where
many people will ignore it.


anand写道:

********************** **************************** ********************** **************************** *******

#include< stdio.h>
#include< conio.h>
#include< math.h>

void main()
{
双a,b,c, fa,fb,fc,err;
int count;
clrscr();

************************************************** ************************************************** *******

#include<stdio.h>
#include<conio.h>
#include<math.h>

void main()
{
double a,b,c,fa,fb,fc,err;
int count;
clrscr();




它不会编译。没有像conio.h这样的头文件。

没有像clrscr()这样的例程。 main返回一个int,而不是void。我没有看得更远。


至少在C中。如果你使用其他语言模糊

的相似之处C你需要使用一个处理那种

语言的新闻组。这不是它。


-

"如果你想通过groups.google.com发布一个后续,不要使用

破损的回复链接在文章的底部。点击

" show options"在文章的顶部,然后点击

回复在文章标题的底部。 - Keith Thompson

更多详细信息:< http://cfaj.freeshell.org/google/>

另见< http://www.safalra .com / special / googlegroupsreply />



It won''t compile. There is no such header file as conio.h. There
is no such routine as clrscr(). main returns an int, not void. I
did not look further.

At least in C. If you are using some other language with vague
similarities to C you need to use a newsgroup that deals with that
language. This is not it.

--
"If you want to post a followup via groups.google.com, don''t use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers." - Keith Thompson
More details at: <http://cfaj.freeshell.org/google/>
Also see <http://www.safalra.com/special/googlegroupsreply/>


这篇关于需要编译这个(试图找到二分的根)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆