第二讲 C#语言基础(数据类型)
- 格式:ppt
- 大小:1.16 MB
- 文档页数:54
郑州信息科技职业学院教案授课题目:C语言的运算符和表达式、数据类型的转换第二讲:C语言的运算符和表达式、数据类型的转换授课时数:3教学目的与教学要求:1、掌握C语言的各种运算;2、掌握C语言中运算过程中不同的数据类型的转换。
主要内容:1、算术运算符和算术表达式;2、关系运算和逻辑运算;3、自增、自减运算;4、赋值运算;5、其他运算;6、表达式和表达式语句;7、自动类型转换和赋值转换;8、强制类型转换。
重点和难点:1、自增、自减运算;2、自动类型转换和赋值转换;3、强制类型转换。
教学方法和手段教具多媒体演示和板书相结合授课内容:第三章3、1运算符与表达式C的运算符有以下几类:本章主要介绍算术运算符(包括自增自减运算符)、赋值运算符、逗号运算符,其它运算符在以后相关章节中结合有关内容陆续进行介绍。
3、1、1 算术运算符和算术表达式1、算术运算符+(加法运算符。
如3+5)-(减法运算符或负值运算符。
如5-2,-3)*(乘法运算符。
如3*5)/(除法运算符。
如5/3,5.0/3)%(模运算符或求余运算符,%要求两侧均为整型数据。
如7%4的值为3)。
除了负值运算符-单目运算符外,其它都是双目运算符。
说明:(1)两个整数相除的结果为整数,如5/3的结果为1,舍去小数部分。
(2)如果参加+,-,*,/运算的两个数有一个为实数,则结果为double型,因为所有实数都按double 型进行计算。
(3)求余运算符%,要求两个操作数均为整型,结果为两数相除所得的余数。
求余也称为求模。
一般情况,余数的符号与被除数符号相同。
例如:-8%5=-3;8%-5=32、算术表达式算术表达式:用算术运算符和括号将运算对象(也称操作数)连接起来的、符合C语法规则的式子,称为算术表达式。
运算对象可以是常量、变量、函数等。
例如,下面是一个合法的C算术表达式。
a*b/c-1.5+’a’。
注意:C语言算术表达式的书写形式与数学表达式的书写形式有一定的区别:(1)C语言算术表达式的乘号(*)不能省略。
only once and understand it, so they can save time for doing other things. Other students, however, might need to listen to the same dialogue again and again to understand it. Using iPads is especially h__72__ to the students who are learning a language at different paces.The students who are using the new tool in some courses are also happy. They believe that using iPads is a more enjoyable way to learn (like listening to stories and watching movies). The class has become much more interesting and creative.There are other advantages for students. By using iPads, they can pay some attention to the material and learn more. Teaching notes are s__73__ in their iPads and are easy to find. Some students spend more time studying now. "I can listen to my language material or watch teaching videos on the bus, instead of having to wait till I get home," a student explained.But many adults c__74__ that technologies like iPads are doing harm to students. They worry that students might use iPads to download teaching notes and use them to chest during exams. Some believe that iPads may separate students from each other. If a student spends more time watching videos on an iPad, he will have f__75__ chances to have face-to-face communication with others.However, technologies are a__76__ a part of most students' day-to-day lives. As for cheating, teachers can ask students to hand in their iPads when they take exams. Education needs to make c__77__ with the times as technology is playing an important part. We should look forward to a wonderful future when iPads and other technologies can add a lot to the classroom.71. including 72. helpful 73. stored 74. complain 75. few 76. already 77. changes首字母填空同步练习3 (2014中考)A school newspaper T h e Te e n s asked over one thousand teenagers how they spent theirspare time. Here they report the r 81 of the survey. It’s not at all surprising to learn that mostteens said they wanted more free time. Most have less than an hour a day for after-school activities.P 82 activity was popular among both girls and boys, averaging between three to six首字母填空同步练习4 (2017中考)A Delicious MealTony is Chinese American. His family members gather together and serve a traditional Chinese meal once a week. Last week Tony i_______1______his friend Amy for it.Tony’s family was preparing dinner when Amy arrived. The family was cooking vegetables with hot oil. The k______2____ was filled with many good smells. “You can help me set the table.” Tony told his friend. They gave each person a pair of chopsticks, a soup bowl, a soup spoon, and a rice bowl on a plate.“Where are the forks and knives?” Amy asked.“Oh, you won’t n ____3_____those.” Tony explained.” I will show you how to use chopsticks. Don’t worry.”Tony’s mother put different foods which were unfamiliar to Amy onto big plates. She asked the kids to carry the food-filled plates out to the table. Amy carried roast duck. It was one of the f _____4_____dishes she recognized.Amy was a little nervous about eating with chopsticks. Tony gave her instructions on how to do it. Amy finally managed to hold the chopsticks. Just when she picked up a piece of chicken in her chopsticks, her fingers s___5_____ lost control of them, and the chicken flew across the table. It landed in Tony’s soup with a splash(飞溅). E___6______ at the table smiled.Tony’s father kindly brought out a fork and knife. He handed them to Amy .Amy felt more c__7_______. She ate the rest of her dinner easily. It was delicious!At the end of the meal, Amy was given a fortune cookie(签语饼干). She broke itopen and read the small note inside,” If you practice hard, you will learn many things.” Amy laughed and said,” if you let me take home a pair of chopsticks, my fortune may come true!1. invited2. kitchen3. need4. few5. suddenly6. Everyone7. comfortable【解析】试题分析:本文记叙了美国女孩Amy在好朋友Tony(华侨)家参加家宴的有趣故事。
第二讲主要内容运算符表达式一.运算符1.算术运算符和算术表达式C语言的运算符具有不同的优先级,而且还有一个特点,就是它的结合性。
在表达式中,各运算量参与运算的先后顺序不仅要遵守运算符优先级别的规定,还要受运算符结合性的制约,以便确定是自左向右进行运算还是自右向左进行运算。
这种结合性是其它高级语言的运算符所没有的,因此也增加了C语言的复杂性。
C运算符简介C语言的运算符可分为以下几类:1.算术运算符:用于各类数值运算。
包括加(+)、减(-)、乘(*)、除(/)、求余(或称模运算,%)、自增(++)、自减(--)共七种。
2.关系运算符:用于比较运算。
包括大于(>)、小于(<)、等于(==)、大于等于(>=)、小于等于(<=)和不等于(!=)六种。
3.逻辑运算符:用于逻辑运算。
包括与(&&)、或(||)、非(!)三种。
4.赋值运算符:用于赋值运算,分为简单赋值(=)、复合算术赋值(+=,-=,*=,/=,%=)和复合位运算赋值(&=,|=,^=,>>=,<<=)三类共十一种。
5.逗号运算符:用于把若干表达式组合成一个表达式(,)。
6.指针运算符:用于取内容(*)和取地址(&)二种运算。
7.求字节数运算符:用于计算数据类型所占的字节数(sizeof)。
8.特殊运算符:有括号(),下标[],成员(→,.)等几种。
9.条件运算符:这是一个三目运算符,用于条件求值(?:)。
10.位操作运算符:参与运算的量,按二进制位进行运算。
包括位与(&)、位或(|)、位非(~)、位异或(^)、左移(<<)、右移(>>)六种。
1.1算术运算符和算术表达式1.基本的算术运算符●加法运算符“+”:加法运算符为双目运算符,即应有两个量参与加法运算。
如a+b,4+8等。
具有左结合性。
●减法运算符“-”:减法运算符为双目运算符。
+第二讲 二次函数中有关三角形存在性问题一、课题说明:二、知识梳理:动态几何特点----问题背景是特殊图形,考查问题也是特殊图形,所以要把握好一般与特殊的关系;分析过程中,特别要关注图形的特性(特殊角、特殊图形的性质、图形的特殊位置。
)等。
1.基本步骤:(1)分类讨论 (2)尺规作图 (3)计算 2.常用公式:(1)如果A(x 1,y 1)B(x 2,y 2),那么则它们的中点P 的坐标为((x 1+x 2)/2, (y 1+y 2)/2);(2)直线11b x k y +=(01≠k )与22b x k y +=(02≠k )的位置关系:①两直线平行⇔21k k =且21b b ≠ ②两直线垂直⇔121-=k k po三、典例精讲: 1.等腰三角形问题例1.【A 类】(2015师大4模)uprt 如图,在平面直角坐标系中,抛物线与x 轴交于A 、B 两点(A 在B 的左侧),与y 轴交于点C (0,4),顶点为(1,29). (1)求抛物线的函数表达式;教学目标1、使学生掌握二次函数中特殊三角形存在性问题的解题思路及解题方法;2提高学生的综合分析与解决问题的能力。
教学重点 二次函数图像在等腰三角形、直角三角形、相似三角形存在性问题中的综合应用。
教学难点 让学生学会归纳并熟练掌握类型题的作图方法与解答技巧。
教学方法 分类讨论法、尺规作图、归纳法。
常见考法此类型通常会出现在陕西省中考数学第24题,分值为10分;其他省市中考题与也均以解答题形式出现。
选材程度及数量课堂精讲例题课堂训练题课后作业A 类 1 2B 类 1 1 2C 类211(2)设抛物线的对称轴与x 轴交于点D ,试在对称轴上找出点P ,使△CDP 为等腰三角形,请直接写出满足条件的所有点P 的坐标;【教法参考】(1).分类讨论:分类标准:讨论顶角的位置或者底边的位置例如:本题第二问:在抛物线上找一点p ,使得P D C 、、三点构成等腰三角形,则可分成以下几种情况:(1)当C ∠为顶角时,CP CD = (2)当D ∠为顶角时,DP DC = (3)当P ∠为顶角时,PD PC =(2).尺规作图:两圆一线(①当C ∠为顶角时,以C 为圆心CD 为半径画圆,与对称轴交点即为所求点P ,②当D ∠为顶角时,以D 为圆心DC 为半径画圆,与对称轴交点即为所求点P ,③当P ∠为顶角时,线段DC 的垂直平分线与对称轴交点即为所求点P 。
第二讲 C语言中的数据运算主要内容C语言中的数据类型(浮点、字符型)变量赋值与混合运算算术运算和强制类型转换赋值运算和赋值表达式逗号运算和逗号表达式输入输出再讨论浮点型数据(实型数据)实型变量数据存储:指数形式:符号位 尾数(为[0,1]间的小数) 指数尾数和指数的位数没有统一标准,由各C系统自定。
实型变量的分类类型 字节数 有效数字 表示数值范围float 4 7 10 38 ~10 38double 8 16 10 308 ~10 308 实型变量定义float 变量表;double 变量表;。
说明:double数据的输入格式串是“%lf”或“%le”练习1:编程输入一个 float 数据后直接输出,理解 float 的有效数字。
练习2:编程输入一个double数据后直接输出。
实型常量²十进制小数形式:必须有小数点。
如:3.14159、-23.4563、.5、1.²指数形式:字母e前必须有数字,字母e后必须为整数。
如:1.5e4、6.8e-10说明:n实型常数只以十进制表示n所有实型常数默认为double,加 f或 F显式说明为 floatn绝对值小于1的实数,小数点前的 0可略n Turbo C用默认格式输出实型数时,保留小数点后6位n实型数据易产生误差,对于实型数据的比较,谨用“= =” 。
#include <stdio.h>#include <math.h>main(){int a,b;if(1./41*41==1)a=1;else a=0;if (sqrt(2)*sqrt(2)==2) b=1;else b=0;printf("%d\t%d\n",a,b);}思考1. double 和 float,哪种类型表示的数据精度高?有效位数分别是?2. 用什么格式串输入数据给 double 型变量?3. 用什么格式串输出 double 型数据?4. 目前认识的输出格式串有哪些?5. 3.5 是哪种类型的常量?6. 如何表示 float 型的常量?7. 实型数据可以以八进制或十六进制输出吗?8. 输出 double 型数据的格式串是?字符型数据字符常数n直接表示, 如'a', '9', 'Z'n ASCII码值表示。