c++程序设计基础 1-基本数据与表达式.pptx

c程序设计基础1-基本数据与表达式

1.1 概述 1.2 C++的字符集与词汇 1.3 C++的基本数据类型与存储形式 1.4 数据对象与访问 1.5 表达式 1.6 数据输入和输出 小结第1章 基本数据与表达式1.1 概述1.1.1 程序设计与程序设计语言 程序设计语言 人指挥计算机工作的工具,是由字、词和语法规则构成的指令系统 程序设计 根据特定的问题,使用某种程序设计语言,设计出计算机执行的指令序列主要完成两方面工作:数据描述 (2) 数据处理 1.1 概述1.1.2 一个简单的C++程序问题:输入圆的半径,求圆的周长和面积 数据描述: 半径,周长,面积均用实型数表示数据处理: 输入半径 r; 计算周长 = 2*π*r ; 计算面积 = π* r2 ; 输出半径,周长,面积;例1-1 方法一,用结构化方法编程,求圆的周长和面积 // count the girth and area of circle#includeiostreamusing namespace std ;int main (){ double r, girth, area ; const double PI = 3.1415 ; cout Please input radius:\n ; cin r ; girth = 2 * PI * r ; area = PI * r * r ; cout radius = r endl ; cout girth = girth endl ; cout area = area endl ;}例1-1 方法一,用结构化方法编程,求圆的周长和面积 // count the girth and area of circle#includeiostreamusing namespace std ;int main (){ double r, girth, area ; const double PI = 3.1415 ; cout Please input radius:\n ; cin r ; girth = 2 * PI * r ; area = PI * r * r ; cout radius = r endl ; cout girth = girth endl ; cout area = area endl ;}数据描述例1-1 方法一,用结构化方法编程,求圆的周长和面积 // count the girth and area of circle#includeiostreamusing namespace std ;int main (){ double r, girth, area ; const double PI = 3.1415 ; cout Please input radius:\n ; cin r ; girth = 2 * PI * r ; area = PI * r * r ; cout radius = r endl ; cout girth = girth endl ; cout area = area endl ;}数据处理例1-1 方法一,用结构化方法编程,求圆的周长和面积 // count the girth and area of circle#includeiostreamusing namespace std ;int main (){ double r, girth, area ; const double PI = 3.1415 ; cout Please input radius:\n ; cin r ; girth = 2 * PI * r ; area = PI * r * r ; cout radius = r endl ; cout girth = girth endl ; cout area = area endl ;}输入数据例1-1 方法一,用结构化方法编程,求圆的周长和面积 // count the girth and area of circle#includeiostreamusing namespace std ;int main (){ double r, girth, area ; const double PI = 3.1415 ; cout Please input radius:\n ; cin r ; girth = 2 * PI * r ; area = PI * r * r ; cout radius = r endl ; cout girth = girth endl ; c

文档评论(0)

1亿VIP精品文档

相关文档