发布网友 发布时间:2024-10-24 04:25
共2个回答
热心网友 时间:2024-11-02 05:51
#include <iostream.h>
double Result(int n)
{
double result = 0;
for (int i = 1;i<=n;i++)
{
result += ((double)i+1) /(double)i;
}
return result;
}
void main()
{
char frag = 'Y';
int n;
do
{
cout<<"请输入n:"<<endl;
cin>>n;
cout<<"结果为:"<<Result(n)<<endl;
cout<<"是否继续(Y/N)?"<<endl;
cin>>frag;
} while (frag == 'y'||frag == 'Y');
}
vc6.0编译通过
热心网友 时间:2024-11-02 05:52
哎·····不是吧?这个也不会····找个通向公式嘛