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

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
float x=18.5,y=4.6;
prin tf("%f\n",(float)(a*b)/2); prin tf("%d\n",(i nt)x%(i nt)y); }
3.1(2)
#i nclude<stdio.h> mai n()
{
int x=32,y=81,p,q; p=x++;
q=--y;
prin tf("%d %d\n",p,q); prin tf("%d %d\n",x,y);
3.4
ttinc-udeAsfdio.hv
ttinc-udeAmafh.hv
maino

foafpb-g
doub-ex-y八
prinffQnpufpb"cpscanf(=%f%f%『「QopQob"Qoc)八
XH(—b+sqrt(b*b—4*a*c))、(2*a)八yH(—b—sqrt(b*b—4*a*c))、(2*a)八p「inff(=XH%hyH%f\rrxyx餐4
maino

infab
scanf(=%2d%*2s%2d=QOaQOb=
p「Hf(=%a%2n=pbx
4.2
ttinc-udeAsfdio.hvmaino

ongab
foaf><y八scanf(=%d』%2rrQOaQObxscanf(=%h%f\rrQOxQOy)八p「inff(=aH%d』bH%2rr0b=
P13
ttinc-udeAsfdio.hv
maino
charclHab2Hbb3H-c二prinff(=a%cb%cc%2rTQo2o3=4.1(2)
ttinc-udeAsfdio.hv
maino宀
infaH_kzbH—k5八p「inff(=aH%d%%』bH%d%%一rrab)八
4.1(3)
ttinc-udeAsfdio.hv
printf("Input a year:");
scanf("%d",&year);
flag=year%400==0||year%4==0&&year%100!=0?1:0; if(flag==1&&flag!=0)
{printf("%d is a leap year !\n",year);
}
3.2
#i nclude<stdio.h> mai n()
{
int x,b0,b1,b2,s;
prin tf("I nputx:");
sca nf("%d", &x);
b2=x/100;
b1= (x-b2*100)/10;//或(x%100)/10;或x/10%10;
b0=x%10;
S=b0*100+b1*10+b2;
2
#i nclude<stdio.h> mai n()
{
float x=2.5,y=2.5,z=2.5;
prin tf("x=%f\n",x);
prin tf("y=%f\n",y);
prin tf("z=%f\n",z);
}
3.1(1)
#i nclude<stdio.h> mai n()
{
int a=12,b=3;
}
else
{
printf("不是三角形");
}
}
5.4
#include<stdio.h>
#include<math.h>
main()
{
float a,b,c,x,y;
printf("Inputa,b,c:");
scanf("%f,%f,%f",&a,&b,&c);
if(a==0)
{
printf("该方程不是一元二次方程\n");
}
if(b*b-4*a*c>0)
{
x=(-b+sqrt(b*b-4*a*c))/(2*a); y=(-b-sqrt(b*b-4*a*c))/(2*a);
printf("x=%f,y=%f\n",x,y);
}
else if(b*b-4*a*c==0)
{
x=-b/(2*a);
y=-b/(2*a);
printf("x=%f,y=%f\n",x,y);
prin tf("s=%d\n",s);
}
3.3 #i nclude<stdio.h> #in clude<math.h> mai n()
float rate=0.0225;
float n, capital,deposit; printf("Input n,capital:");
scanf(=%h%f"QOnQOcapiQ)_)八deposiHcapiQr-*powu+「apn)八p「inff(=deposifH%f\n=deposo八
main()
{
float a,b,c,s,area;
printf("Input a, b, c:"); scanf("%f %f %f", &a, &b, &c); if(a+b>c&&a+c>b&&b+c>a){
s=(a+b+c)/2; area=(float)sqrt(s*(s-a)*(s-b)*(s-c)); printf("area=%f\n",area);
}
else
{
printf("该方程无实根\n");
}
}
5.5
#include<stdio.h>
main()
{
int year,flag;
printf("Input a year:");
scanf("%d",&year);
if(year%4==0&&year%400!=0||year%400==0)
{
flag=1;
}
else
{
flag=0;
}
if(flag==1)
{printf("%d is a leap year !\n",year);
}
else
{
printf("%d is not a leap year !\n",year);
}
}
5.6
#include<stdio.h> main()
{
int year,flag;
}
}
5.2
#include<stdio.h>
main()
{
int a;
printf("Input a:");
scanf("%d", &a);
if(a%2==0)
{
printf("a是偶数");
}
else
{
printf("a是百度文库数");
}
}
5.3
#include<stdio.h>
#include<math.h>
printf("x=%f,b=%f\n",x,y);
}
5.1
#include<stdio.h>
main()
{
float a;
printf("Input a:");
scanf("%f",&a);
if(a>=0)
{
a=a;
printf("a=%f\n",a);
}
else
{
a=-a;
printf("a=%f\n",a);
相关文档
最新文档