请帮助我纠正此问题 [英] Please Help me in correcting this problem
本文介绍了请帮助我纠正此问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
请帮助我纠正问题
Please Help me in correcting the problem
class power
{
power()
{
int n;
}
void main(int n)
{
int x;
for(x=1;x<=n;x++)
{
sum += Math.pow(x,x+2);
}
System.out.print(sum);
}
}
推荐答案
两件事;
1)永远不会声明总和类型
2)看一下Java规范,Math.pow返回一个double并将2个参数作为double
Two things;
1) sum type is never declared
2) look at the java specification, Math.pow returns a double and take the 2 paramaters as doubles
我建议您看一些 ^ ]可以更好地理解程序的元素.
I suggest you take a look at some of these tutorials[^] to get a better understanding of the elements of your program.
这篇关于请帮助我纠正此问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文