《C语言程序设计》苏小红课后习题答案高等教育出社 下载本文

float a=100.0,c; printf(\scanf(\do {

a=a*(1+c); n++;

}while(a<=200);

printf(\

}

6.8 #include #include main() {

int n=1,count=1;

double sum=1,term=1; while(fabs(term)>=1e-5) {

term=pow(-1,count)*(1.0/(n+2)); sum=sum+term; n=n+2; count++; }

sum=4*sum;

printf( \}

6.9 #include #include main() {

int n=1,count=1;

double sum=1,term=1; while(fabs(term)>=1e-5) {

term=term*(1.0/n); sum=sum+term; n++; count++; }

printf(\}

6.10 #include #include

main() {

int x;

for(x=100;x<=999;x++) {

if(x==pow(x/100,3)+pow(x/10,3)+pow(x,3)) printf(\} }

6.11 #include main() {

int i=0,n;

long sum=0,term=1; printf(\scanf(\do{

i++;

term=term*i; sum=sum+term; }while(sum

6.12 #include main() {

int i,n,m,count=0,sum=0; printf(\ n:\scanf(\

for(i=1;i<=n;i++) {

printf(\scanf(\if(m>0) {

sum=sum+m; count++; } else {

break; }

printf(\

}

}

6.13 #include main() {

int i,n,m,count=0,sum=0; printf(\scanf(\for(i=1;i<=n;i++) {

printf(\scanf(\if(m>0||m<0) {

sum=sum+m; count++; } else {

break; }

printf(\} }

6.14 #include main() {

int x,y,z;

for(x=0;x<=17;x++) {

for(y=0;y<=25;y++) {

3*x+2*y+z==50; z=30-x-y;

if( 3*x+2*y+z==50&&x+y+z==30)

printf(\

} } }

6.15 #include main() {

int x,y;

for(x=0;x<=98;x++)

{

y=98-x;

2*x+4*y==386;

if(x+y==98&&2*x+4*y==386) {

printf(\} }

} 6.16 #include main() {

int x,y,z;

for(x=0;x<=20;x++) {

for(y=0;y<=33;y++) {

3*y+5*x+z/3.0==100; z=100-x-y;

if (5*x+3*y+z/3.0==100&&z+x+y==100) {

printf(\} }

}

}

6.17 #include main() {

int x,y,z;

for(x=1;x<=9;x++) {

for(y=1;y<=17;y++) {

10*x+5*y+z==100; z=50-x-y;

if( 10*x+5*y+z==100&&x+y+z==50&&z>0) {

printf(\} } }