1、二 2.1 #include void main() /本题原考虑 在 16 位机器上 实验目前多为 32 位机器故已过时。 int a = 42486; cout #include const double pi = 3.1415926; void main() double radius1, radius2; cout radius1 radius2; cout #include const double e = 2.718281828; void main() cout void main() cout void main() cout #include #include #includ
2、e void main() float a,b,c,s,area; /printf(“please input 3 sides of one triangle:n“); cout a b c; /输入时以空格作 为数据间隔 s=(a+b+c)/2; area=sqrt(s*(s-a)*(s-b)*(s-c); /printf(“a=%7.2f,b=%7.2f,c=%7.2fn“,a,b,c); cout #include #include float area(float a, float b, float c); /函数声明 void main() float a,b,c; cout a b
3、 c; /输入时以空格作 为数据间隔 float result = area(a,b,c); /函数调用 cout #include double Cylinder(double r, double h); void main() double radius, height; cout radius height; double volume = Cylinder(radius, height); cout void main() int x; cout x; if(x-1 cout a; int c1 = a%3 =0; int c2 = a%5 =0; int c3 = a%7 =0; s
4、witch(c1 void main() int grade; cout grade; if(grade100|grade=90) cout =80) cout =70) cout =60) cout #include void main() double sum=1, t=-1, x; int i=1; cout x; do t*=(-1)*x/i; sum+=t; i+; while(fabs(t)1e-8); cout #include void main() double sum=1, t=-1, x; cout x; int i=1; while(fabs(t)1e-8) t*=(-
5、1)*x/i; sum+=t; i+; cout #include void main() double sum=1, t=-1, x; cout x; for(int i=1; fabs(t)1e-8; i+) t*=(-1)*x/i; sum+=t; cout void main() long sum=0, t=1; for(int i=1; i void main() for(int i=1; i void main() for(int i=1; i void main() float s=100,h=100; for(int i=1; i void main() int peachs=
6、1; for(int i=1; i #include void main() double x, a; cout a; x = a/2; while(fabs(x-a/x)/2)1e-7) x=(x+a/x)/2; cout void main() for(int i=1; i void main() for(int i=1; i #include void main() cout #include void main() cout #include void main() cout void main() int n; long a=1, b=1, c=1, temp; cout n; for(int i=4; i #include #include bool isprime(long n); void main() /input long a,b,l=0; cout a b; cout “primes from “ a “ to “ b “ is n“; /process if(a%2=0) a+; for(long m=a; m=b; m+=2) if(isprime(m) /output if(l+%10=0) cout endl; cout setw(5) m;