知道为什么这个程序没有产生输出? [英] Any idea why this program is not generating an output ?

查看:66
本文介绍了知道为什么这个程序没有产生输出?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

#include< stdio.h>

#include< math.h>

#define M_PI 3.14159


int main(无效)

{

双theta,phi,sinth;

重复计算;

double incr;

双倍;


s = 180 / M_PI; / *转换为弧度* /

incr = 0.5;

theta = 0;


for(theta = incr; theta < 180; theta + = incr)

sinth = sin(s * theta);

for(phi = 0; phi <360; phi + = incr / sinth)

count ++;

printf("%f",count);

返回0;

}

#include <stdio.h>
#include <math.h>
#define M_PI 3.14159

int main(void)
{
double theta, p sinth;
double count;
double incr;
double s;

s = 180/M_PI; /* converting to radians */
incr = 0.5;
theta = 0;

for(theta = incr; theta < 180; theta += incr)
sinth = sin(s *theta);
for(phi = 0; phi < 360 ; phi += incr/ sinth)
count ++;
printf("%f", count);
return 0;
}

推荐答案

lector写道:

[主题:知道为什么这个程序没有生成输出?]
lector wrote:
[subject: Any idea why this program is not generating an output ?]

#include< stdio.h>

#include< math.h>

#define M_PI 3.14159


int main(无效)

{

双theta,phi,sinth;

重复计算;
#include <stdio.h>
#include <math.h>
#define M_PI 3.14159

int main(void)
{
double theta, p sinth;
double count;



lector.c:8:警告:''count''可以在这个

函数中未初始化使用

lector.c:8: warning: ''count'' may be used uninitialized in this
function


double incr;

double s;


s = 180 / M_PI; / *转换为弧度* /
double incr;
double s;

s = 180/M_PI; /* converting to radians */



如果你_sivide_ by s,也许。

If you _divide_ by s, perhaps.


incr = 0.5 ;

theta = 0;


for(theta = incr; theta< 180; theta + = incr)

sinth = sin(s * theta);
incr = 0.5;
theta = 0;

for(theta = incr; theta < 180; theta += incr)
sinth = sin(s *theta);



尝试添加...


printf("%f\ n",sinth);


再次运行,然后问问自己为什么不打印。

Try adding...

printf("%f\n", sinth);

Run it again, then ask yourself why it doesn''t print.


for(phi = 0; phi <360 ; phi + = incr / sinth)

count ++;

printf("%f",count);

返回0;

}
for(phi = 0; phi < 360 ; phi += incr/ sinth)
count ++;
printf("%f", count);
return 0;
}



-

Peter

--
Peter


4月8日,06:53,lector< hannibal.lecto ... @ gmail.comwrote:
On 8 Apr, 06:53, lector <hannibal.lecto...@gmail.comwrote:

#include< stdio.h>

#include< math.h>

#define M_PI 3.14159
#include <stdio.h>
#include <math.h>
#define M_PI 3.14159



为什么重新定义M_PI?在我的math.h中,给它一个值为3.14159265358979323846的值
。你通过重新加工它会失去很多精确度,而且不会获得任何收益。我很惊讶

你没有得到编译器警告。

Why redefine M_PI? In my math.h, it is given a value
of 3.14159265358979323846. You lose a lot of precision
by redifining it, and don''t gain anything. I''m surprised
you don''t get a compiler warning.


4月8日上午11:02,Peter Nilsson< ; ai ... @ acay.com.auwrote:
On Apr 8, 11:02 am, Peter Nilsson <ai...@acay.com.auwrote:

lector写道:


[主题:任何想法为什么会这样程序没有生成输出?]
lector wrote:

[subject: Any idea why this program is not generating an output ?]

#include< stdio.h>

#include< math.h>

#define M_PI 3.14159
#include <stdio.h>
#include <math.h>
#define M_PI 3.14159


int main(void)

{

double theta,phi,sinth;

重复计算;
int main(void)
{
double theta, p sinth;
double count;



lector.c:8:警告:''count''可以在这个

函数中未初始化使用


lector.c:8: warning: ''count'' may be used uninitialized in this
function


double incr;

double s;
double incr;
double s;


s = 180 / M_PI; / *转换为弧度* /
s = 180/M_PI; /* converting to radians */



如果你_divide_ by s,也许。


If you _divide_ by s, perhaps.


incr = 0.5 ;

theta = 0;
incr = 0.5;
theta = 0;


for(theta = incr; theta< 180; theta + = incr)

sinth = sin(s * THETA);
for(theta = incr; theta < 180; theta += incr)
sinth = sin(s *theta);



尝试添加...


printf("%f\ n",sinth);


再次运行,然后问问自己为什么不打印。


Try adding...

printf("%f\n", sinth);

Run it again, then ask yourself why it doesn''t print.


for(phi = 0; phi <360 ; phi + = incr / sinth)

count ++;

printf("%f",count);

返回0;

}
for(phi = 0; phi < 360 ; phi += incr/ sinth)
count ++;
printf("%f", count);
return 0;
}



*修改*


#include< stdio。 h>

#include< math.h>

#define M_PI 3.14159

int main(无效)

{

双theta,phi,sinth;

重复计算;

double incr;

double s;


s = 180 / M_PI;

incr = 0.05;

theta = 0;

count = 0;


for(theta = incr; theta< 180; theta + = incr)

{sinth = sin(theta / s); printf("%f\ n,sinth);

for(phi = 0; phi< 360; phi + = incr / sinth)

count + +;

}

printf("%f",count);

返回0;

}

运行得非常好。谢谢。


*modified*

#include <stdio.h>
#include <math.h>
#define M_PI 3.14159
int main(void)
{
double theta, p sinth ;
double count;
double incr;
double s;

s = 180/M_PI;
incr = 0.05;
theta = 0;
count = 0;

for(theta = incr; theta < 180; theta += incr)
{ sinth = sin(theta/s); printf("%f\n",sinth);
for(phi = 0; phi < 360 ; phi += incr/ sinth)
count ++;
}
printf("%f", count);
return 0;
}
Runs perfectly well. Thanks.


这篇关于知道为什么这个程序没有产生输出?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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