c语言程序设计胡成松电子版,C语言程序设计教学课件 作者 胡成松 黄玉兰 李文红 课后习题解答 习题答案 3简单程序设计 .docx...

3.1源程序如下:

#include

#include

int main(void)

{

float a,b,c,s,area;

scanf("%f,%f,%f",&a,&b,&c);

s=1.0/2*(a+b+c);

area=sqrt(s*(s-a)*(s-b)*(s-c));

printf("a=%7.2f,b=%7.2f,c=%7.2f,s=%7.2f\n",a,b,c,s);

printf("area=%7.2f\n",area);

return 0;

}

3.2源程序如下:

#include "stdio.h"

void main()

{ int iNum;

int i1,i2,i3,iSum;

printf("please input a integer(100-999):");

scanf("%d",&iNum);

i1=iNum%10; /*求个位数*/

i2=iNum/10%10; /*求十位数*/

i3=iNum/100; /*求百位数*/

iSum=i1+i2+i3;

printf("The sum is: %d",iSum);

getch();

}

3.3 源程序如下:

#include "stdio.h"

int main()

{

int iNum, r=5,c,s;

printf("r=%d\nc=%f\ns=%f",5,2*3.14*r,3.14*r*r);

getch();

}

3.4 源程序如下:

#include "stdio.h"

void main()

{

int a,b,A,B,C,D;

printf("Please input a b:");

scanf("%d%d",&a,&b);

A=a+b;

B=a-b;

C=a*b;

D=a%b;

printf("a+b=%d\t,\na-b=%d\t,\na*b=%d\t,\na%b=%d\t",A,B,C,D);

getch();

}

3.5 源程序如下:

#include "stdio.h"

void main()

{ char s;

printf("please enter ane character amony s-z:");

s=getchar();

s=s-32;

printf(" %c",s);

getchar();

getch();

}

3.6 源程序如下:

1:

#include "stdio.h"

#include "conio.h"

main()

{ int a,b,c,d,e,f;

a=2187/100;

b=2187%100/50;

c=2187%100%50/20;

d=2187%100%50%20/10;

e=2187%100%50%20%10/5;

f=2187%100%50%20%10%5/1;

printf(" %d\t%d\t%d\t%d\t%d\t%d",a,b,c,d,e,f);

getch();

}

2

#include "stdio.h"

#include "conio.h"

void main()

{ int a,b,c,d,e,f,k1,k2,k3,k4,k5;

k1=2187%100;

k2=k1%50;

k3=k2%20;

k4=k3%10;k5=k4%5;

a=2187/100;

b=k1/50;

c=k2/20;

d=k3/10;

e=k4/5;

f=k5/1;

printf(" %d\t%d\t%d\t%d\t%d\t%d",a,b,c,d,e,f);

getch();

}

3.7 源程序如下:

#include "stdio.h"

#define PAI 3.1415926 /*定义符号常量PAI*/

void main()

{

float fRadius,fVolume; /*定义浮点变量*/

printf("please input the ball's radius:");

scanf("%f",&fRadius);

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值