資源描述:
《湘潭大學(xué)生c語(yǔ)言課后習(xí)題答案》由會(huì)員上傳分享,免費(fèi)在線閱讀,更多相關(guān)內(nèi)容在教育資源-天天文庫(kù)。
1、.5.2#includevoidmain(){inta,b,c,num,n;printf("請(qǐng)輸入一個(gè)三位數(shù):");scanf("%d",&num);c=num%10;b=(num/10)%10;a=num/100;if(a==b&&a!=c)n=1;elseif(a==c&&a!=b)n=1;elseif(b==c&&a!=b)n=1;elsen=0;if(n)printf("%d",num);}5.3#include#includevoidmain(){intx;doubley;scanf("%d",&x);/*輸入x*/swit
2、ch(x/10){case0:y=cos(x+3.0);break;case1:y=pow(cos(x+7.5),2);break;case2:y=pow(cos(x+4.0),4);break;}printf("%lf",y);}5.4#includevoidmain(){intnum,i,leap;scanf("%d",&num);if(num%2!=0){printf("是奇數(shù)");if(num>1){for(i=2;i<=num/2;i++){if(num%i==0){leap=0;break;}elseleap=1;}if(leap)printf("是素?cái)?shù)
3、n");elseprintf("不是素?cái)?shù)");}}elseprintf("是偶數(shù)");}5.5#includevoidmain(){inta,b,c,i,n;for(i=0;i<10000;i++){for(n=1;n<10000;n++){a=i;b=a+n;c=b+n;if(a*c==5*b&&b+c==8*a){printf("%d,%d,%d",a,b,c);break;}}}}6.1#include#includevoidmain(){doublem=1.0,p=0.0;intk=1,n=1;do{m=1.0/n;n=n
4、+2;if(k%2==0)m=(-1.0)*m;p=p+m;k++;}while(fabs(m)>=1e-6);p=p*4.0;......printf("%lf",p);}6.2#includevoidmain(){intk,k1=1,k2=1,k3;floatp=0,m;for(k=1;k<=20;k++){k3=k1+k2;m=(float)k3/k2;p=p+m;k1=k2;k2=k3;}printf("%f",p);}6.3(1).#includevoidmain(){inti,j,k;for(i=0;i<=4;i++){for(j=0;j
5、<=3-i;j++)printf("");for(k=0;k<=2*i;k++)printf("*");printf("");}for(i=0;i<=3;i++){for(j=0;j<=i;j++)printf("");for(k=0;k<=6-2*i;k++)printf("*");printf("");}}(2.)#includevoidmain(){inti,j,k;charc=65;for(i=0;i<=4;i++){for(j=0;j<=3-i;j++)printf("");for(k=0;k<=2*i;k++)printf("%c",c);printf("
6、");c=c+1;}for(i=0;i<=3;i++){for(j=0;j<=i;j++)printf("");for(k=0;k<=6-2*i;k++)printf("%c",c);printf("");c=c+1;}}6.4#includevoidmain(){inta,b,i,n;for(a=1;a<3000;a++){for(b=0,i=1;i<=a/2;i++)if(a%i==0)b=b+i;for(n=0,i=1;i<=b/2;i++)if(b%i==0)n=n+i;if(n==a&&a7、ude#includevoidmain(){intnum,a,b,c,p;......for(num=100;num<1000;num++){c=num%10;b=num/10%10;a=num/100;p=pow(a,3)+pow(b,3)+pow(c,3);if(num==p)printf("%d",num);}}6.6#includev