[英] Values

查看:67
本文介绍了值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的表情很难给我正确的结果。


int healer()

{

printf(\ nOrko the Healer \ n);

printf(你的健康:(%d)/(%d)\ n \ n,,calth,cmaxhealth );

heal =(cmaxhealth - chealth);

heal * = 2;

printf("%d gold to heal.\\ \\ n \\ n'\\ n',治愈;

}


为什么变量治愈总是导致0而变量

chealth和cmaxhealth在2到16之间?我该如何解决这个问题?


任何帮助都将不胜感激...谢谢。


- Jon

解决方案

Jonathan H. Justvig写道:


我在表达方面遇到麻烦,给我正确的结果。


int healer()

{

printf(\ nOrko the Healer \ n);

printf("你的健康:(%d)/(%d)\ n \ n",chealth,cmaxhealth);

heal =(cmaxhealth - chealth) ;

治愈* = 2;

printf(%d gold to heal.\\\
\ n,治愈);

}


为什么变量愈合总是导致0而变量

chealth和cmaxhealth在2到16之间?我怎样才能解决这个问题?



尝试发布显示问题的最小可编辑片段。

你没有显示治疗,秘密或cmaxhealth的声明,

更不用说你用来将值放入它们的方法了。


猜测,%d对于变量治愈是错误的,但直到你发布

缺少的细节,所有你得到的都是水晶球的答案。


-

彼得


Peter Nilsson写道:


尝试发布显示问题的最小可编辑片段。

你没有显示治愈,健康或cmaxhealth的声明,

更不用说你用来给它们输入值的方法了。


猜测,%d对于变量治疗是错误的,但是直到你发布了缺失的细节,所有你得到的都是水晶球的答案。



我道歉,这是我发给新闻组的第一篇文章。试试这个...


int heal,chealth,cmaxhealth;

int cstr,cdex,cint,cvit;


- snip


int class()

{

srand(time(NULL));

cvit = rand()%8 + 1;

cvit + = rand()%8 + 1;

printf(你的活力:% d \ n",cvit);

cmaxhealth = cvit / 2;

chealth = cmaxhealth;

printf(" Your Health: (%d /%d)\ n \ n",chealth,cmaxhealth);


}


- snip


int healer()

{

printf(\ nOrko the Healer \ n);

printf("你的健康:(%d)/(%d)\ n \ n",chealth,cmaxhealth);

heal =(cmaxhealth - chealth);

治愈* = 2;

printf(%d gold to heal.\\\
\ n,治愈);

}


- snip


我希望这会有所帮助,尽管它可能/可能无法编译。为了拯救灾难,

我真的不想在新闻组中发布整个来源。谢谢

快速回复。


- Jon




Jonathan H. Justvig写道:


int heal,chealth,cmaxhealth;

int cstr,cdex,cint,cvit;


- snip


int class()

{

srand(time( NULL));

cvit = rand()%8 + 1;

cvit + = rand()%8 + 1;

printf (你的活力:%d \ n,cvit);

cmaxhealth = cvit / 2;

chealth = cmaxhealth;



最初你将生命值设置为最大生命值


printf(" Your Health:(%d / %d)\ n \ n ,chealth,cmaxhealth);


}


- snip


int healer()

{

printf(\ nOrko the Healer \ n);

printf(你的健康:(%d)/(%d)\ n \ n,chealth,cmaxhealth);

heal =(cmaxhealth - chealth);

治愈* = 2;



在这里你比较健康。你在哪里减少健康吗?

直到发生这种情况,治疗将为零。


printf("%d gold to heal.\\\
\ n,heal);

}

I''m having trouble with expressions giving me the right results.

int healer()
{
printf ("\nOrko the Healer\n");
printf ("Your health: (%d)/(%d)\n\n", chealth, cmaxhealth);
heal = (cmaxhealth - chealth);
heal *= 2;
printf ("%d gold to heal.\n\n", heal);
}

Why does the variable heal always result in 0 while the variables
chealth and cmaxhealth are between 2 and 16? How can I fix this?

Any help would be appreciated... Thanks.

-- Jon

解决方案

Jonathan H. Justvig wrote:

I''m having trouble with expressions giving me the right results.

int healer()
{
printf ("\nOrko the Healer\n");
printf ("Your health: (%d)/(%d)\n\n", chealth, cmaxhealth);
heal = (cmaxhealth - chealth);
heal *= 2;
printf ("%d gold to heal.\n\n", heal);
}

Why does the variable heal always result in 0 while the variables
chealth and cmaxhealth are between 2 and 16? How can I fix this?

Try posting the smallest compilable snippet that exhibits the problem.
You haven''t shown the declarations of heal, chealth or cmaxhealth,
let alone the methods you used to put values into them.

At a guess, %d is wrong for the variable heal, but until you post
the missing details, all you''ll get are answers from the crystal ball.

--
Peter


Peter Nilsson wrote:

Try posting the smallest compilable snippet that exhibits the problem.
You haven''t shown the declarations of heal, chealth or cmaxhealth,
let alone the methods you used to put values into them.

At a guess, %d is wrong for the variable heal, but until you post
the missing details, all you''ll get are answers from the crystal ball.

I apologize, my very first post to a newsgroup. Try this...

int heal, chealth, cmaxhealth;
int cstr, cdex, cint, cvit;

-- snip

int class()
{
srand ( time(NULL) );
cvit = rand()%8+1;
cvit += rand()%8+1;
printf ("Your Vitality: %d\n", cvit);
cmaxhealth = cvit / 2;
chealth = cmaxhealth;
printf ("Your Health: (%d/%d)\n\n", chealth, cmaxhealth);

}

-- snip

int healer()
{
printf ("\nOrko the Healer\n");
printf ("Your health: (%d)/(%d)\n\n", chealth, cmaxhealth);
heal = (cmaxhealth - chealth);
heal *= 2;
printf ("%d gold to heal.\n\n", heal);
}

-- snip

I hope this helps, although it may/may not compile. To save disasters,
I don''t really want to post the entire source in a newsgroup. Thanks
for the quick response.

-- Jon



Jonathan H. Justvig wrote:

int heal, chealth, cmaxhealth;
int cstr, cdex, cint, cvit;

-- snip

int class()
{
srand ( time(NULL) );
cvit = rand()%8+1;
cvit += rand()%8+1;
printf ("Your Vitality: %d\n", cvit);
cmaxhealth = cvit / 2;
chealth = cmaxhealth;

Initially you set health to max health

printf ("Your Health: (%d/%d)\n\n", chealth, cmaxhealth);

}

-- snip

int healer()
{
printf ("\nOrko the Healer\n");
printf ("Your health: (%d)/(%d)\n\n", chealth, cmaxhealth);
heal = (cmaxhealth - chealth);
heal *= 2;

Here you are comparing health.Did you reduce health somewhere?
Untill that happens, heal will be zero.

printf ("%d gold to heal.\n\n", heal);
}


这篇关于值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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