- 2
- 0
- 约1.32万字
- 约 104页
- 2017-04-27 发布于四川
- 举报
吉林大学程序设计基础教材第2章简单程序设计
求绿化带宽度
语句(Statement)
表达式(Expression)
基本符号
数据(Data)
数据类型(Data Type)
输入/输出(Output/Input)
顺序控制结构(Sequence Control Structure);图2.1 保护地块;第一步,把问题数学化
area=(length-2*x)*(width-2*x)
4x2 - 2(length+width)x +length*width-area= 0
第二步,找出计算方法
;第三步,找出算法
;第四步,用C写出程序
#include stdio.h
#include math.h
#define length 500 // 地块长
#define width 300 // 地块宽
#define area 80000 // 地块面积
void main(){
float x1,x2,b,d;
b= -2.0*(length+width); // 计算b
d=sqrt(b*b - 4.0*4.0*(length*width –area)); // 计算△
x1=(-b+d)/(2*4); // 求根
x2=(-b-d)/(2*4);
printf
原创力文档

文档评论(0)