C语言程序设计实验与习题指导课后程序设计答案,DOC
合集下载
相关主题
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
{
intcelsius,fahr;
printf("Entercelsius:");
scanf("%d",&celsius);
fahr=9*celsius/5+32;
printf("fahr%d\n",fahr);
return0;
}
(2)
#include<stdio.h>
#include<math.h>
return0;
}
scanf("%d",&y);
printf("%d+%d=%d\n",x,y,x+y);
printf("%d-%d=%d\n源自文库,x,y,x-y);
printf("%d*%d=%d\n",x,y,x*y);
printf("%d/%d=%d\n",x,y,x/y);
printf("%d%%%d=%d\n",x,y,x%y);
{
intn,a,b,c;
n=152;
c=n%10;
b=(n/10)%10;
a=n/100;
printf("整数%d的个位数字是%d,十位数字是%d,百位数字是%d\n",n,c,b,a);
return0;
}
P27
(1)
#include<stdio.h>
#include<math.h>
intmain(void)
intmain(void)
{
intmoney,year;
doublerate,interest;
printf("Entermoney,year,rate:");
scanf("%d%d%lf",&money,&year,&rate);
interest=money*pow(1+rate,year)-money;
printf("interest=%.2f\n",interest);
return0;
}
(3)
#include<stdio.h>
#include<math.h>
intmain(void)
{
doublex,y;
printf("Enterx:");
scanf("%lf",&x);
if(x<0){
y=pow(x+1,2)+2*x+1/x;
math=87;
eng=72;
comp=93;
average=(math+eng+comp)/3;
printf("math=%d,eng=%d,comp=%d,average=%d\n",math,eng,comp,average);
return0;
}
(4)
#include<stdio.h>
intmain(void)
intmain(void)
{
intcelsius,fahr;
celsius=26;
fahr=9*celsius/5+32;
printf("celsius=%d,fahr=%d\n",celsius,fahr);
return0;
}
(3)
#include<stdio.h>
intmain(void)
{
intaverage,math,eng,comp;
}
else{
y=sqrt(x);
}
printf("y=f(%f)=%.2f\n",x,y);
return0;
}
(4)
#include<stdio.h>
intmain(void)
{
intx,y;
printf("Enternum1:");
scanf("%d",&x);
printf("Enternum2:");
return0;
}
10的阶乘
#include<stdio.h>
intmain(void)
{
inti,n,product;
printf("Entern:");
scanf("%d",&n);
product=1;
for(i=1;i<=n;i++){
product=product*i;
}
printf("product=%d\n",product);
P18
(1)
#include<stdio.h>
intmain(void)
{
intcelsius,fahr;
fahr=150;
celsius=5*fahr/9-5*32/9;
printf("fahr=%d,celsius=%d\n",fahr,celsius);
return0;
}
(2)
#include<stdio.h>
intcelsius,fahr;
printf("Entercelsius:");
scanf("%d",&celsius);
fahr=9*celsius/5+32;
printf("fahr%d\n",fahr);
return0;
}
(2)
#include<stdio.h>
#include<math.h>
return0;
}
scanf("%d",&y);
printf("%d+%d=%d\n",x,y,x+y);
printf("%d-%d=%d\n源自文库,x,y,x-y);
printf("%d*%d=%d\n",x,y,x*y);
printf("%d/%d=%d\n",x,y,x/y);
printf("%d%%%d=%d\n",x,y,x%y);
{
intn,a,b,c;
n=152;
c=n%10;
b=(n/10)%10;
a=n/100;
printf("整数%d的个位数字是%d,十位数字是%d,百位数字是%d\n",n,c,b,a);
return0;
}
P27
(1)
#include<stdio.h>
#include<math.h>
intmain(void)
intmain(void)
{
intmoney,year;
doublerate,interest;
printf("Entermoney,year,rate:");
scanf("%d%d%lf",&money,&year,&rate);
interest=money*pow(1+rate,year)-money;
printf("interest=%.2f\n",interest);
return0;
}
(3)
#include<stdio.h>
#include<math.h>
intmain(void)
{
doublex,y;
printf("Enterx:");
scanf("%lf",&x);
if(x<0){
y=pow(x+1,2)+2*x+1/x;
math=87;
eng=72;
comp=93;
average=(math+eng+comp)/3;
printf("math=%d,eng=%d,comp=%d,average=%d\n",math,eng,comp,average);
return0;
}
(4)
#include<stdio.h>
intmain(void)
intmain(void)
{
intcelsius,fahr;
celsius=26;
fahr=9*celsius/5+32;
printf("celsius=%d,fahr=%d\n",celsius,fahr);
return0;
}
(3)
#include<stdio.h>
intmain(void)
{
intaverage,math,eng,comp;
}
else{
y=sqrt(x);
}
printf("y=f(%f)=%.2f\n",x,y);
return0;
}
(4)
#include<stdio.h>
intmain(void)
{
intx,y;
printf("Enternum1:");
scanf("%d",&x);
printf("Enternum2:");
return0;
}
10的阶乘
#include<stdio.h>
intmain(void)
{
inti,n,product;
printf("Entern:");
scanf("%d",&n);
product=1;
for(i=1;i<=n;i++){
product=product*i;
}
printf("product=%d\n",product);
P18
(1)
#include<stdio.h>
intmain(void)
{
intcelsius,fahr;
fahr=150;
celsius=5*fahr/9-5*32/9;
printf("fahr=%d,celsius=%d\n",fahr,celsius);
return0;
}
(2)
#include<stdio.h>