
求助一道c++的问题!!!
Writeaprogramtocomputethefollowingsum:1.0/n+2.0/(n-1)+3.0/(n-2)+....+(n-1)/2+n/1where...
Write a program to compute the following sum: 1.0/n + 2.0/(n-1) + 3.0/(n-2) + .... +(n-1)/2 + n/1
where n is a positive integer enter by the user. For example,
1) If n=2, the output should be 2.5
2) If n=4, the output shold be 6.4166666
Hint! What is 1/2 in C++? What is 1.0/2 in C++?
Your program should include a loop that lets the user repeat this
calculation until the user says s/he is done. 展开
where n is a positive integer enter by the user. For example,
1) If n=2, the output should be 2.5
2) If n=4, the output shold be 6.4166666
Hint! What is 1/2 in C++? What is 1.0/2 in C++?
Your program should include a loop that lets the user repeat this
calculation until the user says s/he is done. 展开
4个回答
展开全部
全是英文 改成中文
编写一个程序,计算出以下全额:1.0 / n + 2.0 + 3.0(n-1)/(n-2)+ .... +(n-1)/ 2 + n/1
在n是一个正整数输入,由用户。例如,
1)如果2例,输出应该是2.5
2)如果n = 4,输出应当是6.4166666
提示!什么是1/2 c++中吗?什么是1.0 / 2 c++中吗?
你的程序应该包括一个环,让用户重复这个
计算用户说直到他/她是做的。
编写一个程序,计算出以下全额:1.0 / n + 2.0 + 3.0(n-1)/(n-2)+ .... +(n-1)/ 2 + n/1
在n是一个正整数输入,由用户。例如,
1)如果2例,输出应该是2.5
2)如果n = 4,输出应当是6.4166666
提示!什么是1/2 c++中吗?什么是1.0 / 2 c++中吗?
你的程序应该包括一个环,让用户重复这个
计算用户说直到他/她是做的。
追问
好吧...好专业...能帮帮忙吗
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
1.0/n + 2.0/(n-1) + 3.0/(n-2) + .... +(n-1)/2 + n/1
有规律吗??我没看出来
1/n+2/(n-1)+3/(n-2)+.....+怎么能加到(n-1)/2那??
有规律吗??我没看出来
1/n+2/(n-1)+3/(n-2)+.....+怎么能加到(n-1)/2那??
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
虽然没有学过C++,不过我觉得这个题,其实就是考你对C++里面变量类型的了解.
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
。。。问题在哪里?
更多追问追答
追问
刚刚贴上去...
追答
#include
void main()
{
double a;
float sum=0.0;
cout>a;
cout<<endl;
for(int i=0;i<a;i++)
{
sum += float((i+1)/(a-i));
}
cout<<sum<<endl;
}
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询