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

2

#include main() {

float x=2.5,y=2.5,z=2.5; printf(\printf(\printf(\}

3.1(1)

#include main() {

int a=12,b=3;

float x=18.5,y=4.6;

printf(\printf(\}

3.1(2)

#include main() {

int x=32,y=81,p,q; p=x++; q=--y;

printf(\printf(\

.2

}

3.2

#include main() {

int x,b0,b1,b2,s; printf(\scanf(\b2=x/100;

b1=(x-b2*100)/10;//或(x0)/10;或x/10; b0=x;

s=b0*100+b1*10+b2; printf(\}

3.3

#include #include main() {

float rate=0.0225;

float n,capital,deposit; printf(\scanf(\deposit=capital*pow(1+rate,n); printf(\}

3.4

#include #include main() {

float a, b, c; double x, y;

printf(\

scanf(\x=(-b+sqrt(b*b-4*a*c))/(2*a); y=(-b-sqrt(b*b-4*a*c))/(2*a); printf(\}

习题4 4.1(1)

#include main() {

char c1='a',c2='b',c3='c';

printf(\}

4.1(2)

#include main() {

int a=12,b=15;

printf(\}

4.1(3)

#include main() {

int a,b;

scanf(\ printf(\}

4.2

#include main() {

long a,b; float x,y;

scanf(\scanf(\printf(\printf(\} 5.1

#include main() {

float a;

printf(\scanf(\if(a>=0) {

a=a;

printf(\} else {

a=-a;

printf(\} } 5.2

#include main() {

int a;

printf(\scanf(\if(a%2==0) {

printf(\ 是偶数\} else {

printf(\ 是奇数\} } 5.3

#include #include main() {

float a,b,c,s,area; printf(\

scanf(\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(\} else {

printf(\不是三角形\} } 5.4

#include #include main() {

float a,b,c,x,y;

printf(\

scanf(\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(\}

else if(b*b-4*a*c==0) {

x=-b/(2*a); y=-b/(2*a);

printf(\} else {

printf(\该方程无实根\\n\} }

5.5

#include