编写一程序,计算s=1-1/(2*2)+1/(3*3)-1/(4*4)……的前10项的值。
来源:百度知道 编辑:UC知道 时间:2024/06/03 15:16:30
编写一程序,计算s=1-1/(2*2)+1/(3*3)-1/(4*4)……的前10项的值。(要求用函数调用)
#include<iostream>
using namespace std;
void jishu(int n)
{
int k=1;
int a=1;
double s=0;
for(int i=0;i<n;i++)
{
s=s+1/(a*a)*k;
k=-k;
a++;
}
cout<<"结果为:"<<s<<endl;
}
void main()
{
int i;
cout<<"请输入要计算的项数:"<<endl;
cin>>i;
jishu(i);
}
1
这个你自己写不出来?
编写程序,计算和式: S=-1!+2!-3!+4! - …… + 10! 。 要求用循环语句实现。
vfp程序 s=1+2+…… 怎么编写
用VFP编写程序,计算数列前40项之和:S=1/1+2/2+4/3+7/4+11/5...
请写代码!(1)用递归方法编写一程序计算n!的值!急!!!
编写程序计算并输出S=5+10+45+20+.......2000的值
计算s=1!+2!+3!+.....+7!? 用VC编写谢谢?
编写程序计算S=1+1+2+1+2+3+1+2+3+4+……+1+2+3+4+……+n,n的最小值和此时的S值
用VFP编写程序计算T=1+5+10+……+105。怎么编?
java编写程序计算
用两中循环语句编写程序s=1^2+2^2+3^2+...+100^2