C语言程序设计教程_杨路明__课后习题答案 下载本文

第五章

1、void main() int n,value; int i,count=0; float average = 0; long int sum = 0; scanf(\for(i = 0; i scanf(\if(value%2 == 0) sum =value; count ;

average = sum / (float)count; printf(\2、

#include \void main() char ch;

int zm = 0, sz = 0; ch = getchar(); while(ch != '*')

if((ch >= 'A' && ch = 'a' && ch zm ;

if(ch >= '0' && ch sz ;

ch = getchar();

printf(\3、 void main() long i_value;

int sum = 0; int temp = 0;

scanf(\if(i_value for(;;)

temp = i_value_; i_value = i_value/10; sum =temp;

printf(\if(i_value == 0)break; printf(\=%d\4、

#include \void main() char ch; ch = getchar(); while(ch != '.') if((ch >= 'A' && ch ch = ch 32; putchar(ch);

else if((ch >= 'a' && ch ch = ch - 32; putchar(ch); else putchar(ch); ch = getchar(); printf(\5、 void main() float sum = 200; int count = 0;

for(;;)

sum = sum sum*0.045; count ;

if(sum > 500)break;

printf(\6、 void main() int i,temp=0,bit=0; for(i = 1 ; i if(i%3 == 0) temp = i; for(;temp != 0;) bit = temp_;

if(bit == 5)printf(\temp = temp/10; printf(\\7、 #include int main(void) int steps = 29, i = 1; while ( steps % 7 ) steps = (30 * i) - 1;

printf(\return 0; 8、 main() int i,j,k,n;

printf(\for(n=100;n i=n/100; j=n/10-i*10;

k=n_;

if(i*i*i j*j*j k*k*k==n) printf(\9、 main()

float i,j,temp,n,sum; int t; i=2;j=1;sum=0; scanf(\for(n=1;n sum=sum i/j; temp=i;i=i j;j=temp;

printf(\10、 void main() int nWidth,a,b; scanf(\for(a=(nWidth%2);a for(b=0;b char chOut =' ';

int nleft =(nWidth -a)/2; int nright = (nWidth a)/2; if(b>=nleft&&b chOut ='*'; printf(\printf(\11、 void main() int i=1,j=1; for(i=1;i for(j=1;j

printf(\