nt s, n, 1, J; for(j=0,i=1;i<=10;i+) for(s=0,n=1;n<=i;n+) s*n;} J+=s I cout<<j<<end1 第6题编一程序,用牛顿迭代法求解2x34x2+3x-6=0在1.5附近的根。 #includesiostream. h> #includesmath.h> void maino
int s,n,i,j; for (j=0,i=1;i<=10;i++) { for (s=0,n=1;n<=i;n++) {s*=n;} j+=s; }cout<<j<<endl; } 第6题 编一程序,用牛顿迭代法求解2x3 -4x2+3x-6=0在1.5附近的根。 #include<iostream.h> #include<math.h> void main() {
double x=0.0.v1 v2 double x1=1.5; while((fabs(x1-x))>0.00000 y1=2*xx*x-4*x*x+3x-6 y2=6*x*x-8*x+3 x1=x-y1/v2 cout<<x<<endl
double x=0.0,y1,y2; double x1=1.5; while((fabs(x1-x))>0.000001) { x=x1; y1=2*x*x*x-4*x*x+3*x-6; y2=6*x*x-8*x+3; x1=x-y1/y2; } cout<<x<<endl; }
第7题编一程序,将输入数据按小于10,10~99,100~999,1000以上分类并 显示。例如,输入358时,显示358is100to999。 #include <iostream.h> void main( i int i cin if(i<10 cout<<i<<is 0 to 9 <<endl else if (i<100) cout<<i<<is 10 to 99<<endl else if (i<1000) cout<<i<<is 100 to 999 <<endl else cout<<i<<" is biger than 1000<<end;
第7题 编一程序,将输入数据按小于10,10~99,100~999,1000 以上分类并 显示。例如,输入358时,显示358 is 100 to 999。 #include <iostream.h> void main() { int i; cin>>i; if(i<10) cout<<i<<"is 0 to 9"<<endl; else if (i<100) cout<<i<<"is 10 to 99"<<endl; else if (i<1000) cout<<i<<"is 100 to 999"<<endl; else cout<<i<<"is biger than 1000"<<endl;}
第8题 #includesiostream. h> void maino int m=3. n=0 for(int i=0; i<7; i++) for(intj=0;j<7;j++) if(j<=(m+n)&&j>=(m-n) cout<<。 else
第8题 #include<iostream.h> void main() { int m=3,n=0; for(int i=0;i<7;i++) { for(int j=0;j<7;j++) { if(j<=(m+n)&&j>=(m-n)) cout<<"*"; else
cout<<! n. cout<<end: if(i<3) n++; else 第9题.编一程序,求满足如下条件的最大的n。 12+22+32+.+n2<1000 #include <iostream.h> void maino f int i=l,S=0, t dotti S+=t
cout<<" "; } cout<<endl; if(i<3) n++; else n--;} } 第9题.编一程序,求满足如下条件的最大的n 。 1 2+22+32+…+n2≤1000 #include <iostream.h> void main() { int i=1, s=0,t; do{t=i*i; s+=t;