C上机作业(第15次)参考答案
- 格式:doc
- 大小:43.00 KB
- 文档页数:5
小学上册英语第二单元真题(含答案)英语试题一、综合题(本题有100小题,每小题1分,共100分.每小题不选、错误,均不给分)1.We will have ______ for dinner tonight. (chicken)2.The bread is _______ (fresh) from the oven.3.Coral reefs are made up of tiny ______ creatures.4.Which planet is closest to the sun?A. VenusB. EarthC. MercuryD. Mars答案:C5.What is the first month of the year?A. DecemberB. JanuaryC. FebruaryD. March6.The mountains are _______ and beautiful.7.Which animal is known for its ability to change color?A. ChameleonB. FrogC. SnakeD. Lizard答案:A8.The chemical formula for nitric acid is __________.9.In a chemical reaction, the concentration of reactants and products can affect the_____ of the reaction.10.The main use of ammonium sulfate is as a _____.11.The dog is _____ (大).12.We need to _______ (保持) a healthy lifestyle.13.The main component of air is __________.14.The __________ (历史的回响) reverberates through ages.15.This girl, ______ (这个女孩), loves to play the flute.16.We went to the ________ last week.17.They are going to ________ a concert.18.What do you call the end of a story?A. BeginningB. MiddleC. ConclusionD. Chapter答案:C19.My friend is always __________ (乐于助人的) when I need help.20.My favorite school event is _______ (运动会).21.My ________ (朋友) is planning a birthday party this weekend.22.What do we call a book of maps?A. AtlasB. DictionaryC. EncyclopediaD. Almanac23. A rabbit loves to munch on ______ (新鲜的胡萝卜).24.Which day is the weekend?A. MondayB. FridayC. SundayD. Wednesday25.The ________ was a major event in the history of international relations.26. A beaker is a common piece of ______ glassware.27.Electric charges can be positive or ______.28.The melting point of ice is _______ degrees Celsius.29.The _____ (松树) stays green all year round.30.The rabbit's fur is very _______ (柔软).31.What is the name of the imaginary line that goes around the Earth?A. EquatorB. LatitudeC. LongitudeD. Meridian答案:A32.What do we call a person who studies animals?A. ZoologistB. BotanistC. BiologistD. Ecologist答案:A33.What is the name of the famous temple in India?A. Taj MahalB. Angkor WatC. Temple of HeavenD. Borobudur答案:A Taj Mahal34.The chemical properties of an element depend on its ______.35.The chemical formula for sodium thiosulfate is ______.36.Can you see the _____ (茎) of the flower?37.My sister is a ______. She loves to explore museums.38.The ancient Romans celebrated festivals to honor their _____.39.I want to travel to ________ (西班牙) someday.40.The porcupine can defend itself with its sharp ________________ (刺).41.The garden is very _______ (美丽的).42.The ancient Romans held gladiatorial _______ in the Colosseum. (比赛)43.What gas do plants absorb from the atmosphere?A. OxygenB. NitrogenC. Carbon DioxideD. Hydrogen答案:C44.What do we call a scientist who studies the structure and function of biological molecules?A. BiochemistB. BiologistC. ChemistD. Geneticist答案:A45.What is the color of the sun?A. BlueB. YellowC. GreenD. Purple答案:B46.In my dream, I can fly like a ______ (鸟). It would be amazing to see the world from above.47.What is the term for the distance between the Earth and the Sun?A. Astronomical UnitB. Light-YearC. ParsecsD. Miles48. A _____ (mortar) is used for herbs and spices.49. A ______ is a large body of ice that moves slowly.50.What do you call the area of land where wild animals live?A. FarmB. JungleC. HabitatD. Zoo答案:C51.The _____ (moon) is bright tonight.52.Did you see that _____ (小鸟) singing in the tree?53.I love to _______ (写小说).54.What is the time at noon?A. 6 AMB. 12 PMC. 3 PMD. 6 PM答案:B55. A tortoise carries its ______ (壳) everywhere.56.The water is ___ (hot).57.My brother is interested in ____ (mathematics).58.We enjoy ______ (去) concerts.59. A cactus can survive in a __________ (干旱的) environment.60.My friend is a talented __________ (摄影师).61.Which insect makes honey?A. AntB. BeeC. FlyD. Mosquito答案:B62.What instrument has a bow and strings?A. FluteB. ViolinC. TromboneD. Clarinet答案:B63.The __________ is a natural area with many trees.64.What is the color of an emerald?A. BlueB. GreenC. RedD. Yellow65.My phone is _______ (关机的).66.__________ (化学应用程序) can improve processes in various industries.67.What is the name of the famous British rock band known for songs like "Hey Jude"?A. The Rolling StonesB. The WhoC. The BeatlesD. Pink Floyd答案:C The Beatles68.Emma is a ______. She likes to read stories.69.What is the name of the chemical element with the symbol "O"?A. OxygenB. HydrogenC. CarbonD. Nitrogen答案:A70.Chemistry is involved in making _____.71.What is the capital of Costa Rica?A. San JoséB. LiberiaC. CartagoD. Alajuela答案:A72.My _____ (外婆) makes the best cookies.73.I want to ________ (collaborate) with others.74.We play _____ (乒乓球) after school.75.What is the name of the famous scientist who developed the theory of evolution?A. Charles DarwinB. Albert EinsteinC. Isaac NewtonD. Nikola Tesla答案:A76.The __________ Sea is located between Europe and Asia.77. A frog can live on land and in ______.78.My grandmother loves __________ (烘焙).79.小河马) wallows in the mud. The ___80.What do we call the study of how living things interact with each other and their environment?A. BiologyB. EcologyC. ChemistryD. Physics81.The sky is _____. (blue/fast/happy)82.What do we call the study of living things?A. BiologyB. ChemistryC. PhysicsD. Geography答案:A83.How many legs does an octopus have?A. EightB. SixC. TenD. Four84.My favorite type of dance is ______.85.I love to eat ______ (冰淇淋) in the summer. My favorite flavor is ______ (巧克力).86.What is the main source of light for Earth?A. StarsB. MoonC. SunD. Fire答案:C87.What do we call a scientist who studies the atmosphere?A. ChemistB. MeteorologistC. GeologistD. Biologist答案:B Meteorologist88.I want to learn to ________ (剪纸) for art class.89.My uncle is a skilled ____ (potter).90.The _____ (seed) needs soil to grow.91.I like to go ______ (钓鱼) with my father on weekends.92.I enjoy playing ______ (棋盘游戏) with my family during the weekends.93.What do you call the layer of gases surrounding the Earth?A. AtmosphereB. StratosphereC. TroposphereD. Exosphere94.The ______ teaches us about literature.95.Which animal is known for its ability to change color?A. ChameleonB. EagleC. SharkD. Penguin答案:A Chameleon96.The flower smells very ______.97.What is the name of the first man on the moon?A. Neil ArmstrongB. Buzz AldrinC. Yuri GagarinD. John Glenn98.Which one is a type of fabric?A. CottonB. WoodC. MetalD. Glass99.Which instrument has keys and is played with fingers?A. GuitarB. FluteC. PianoD. Violin答案:C100.What do you call the liquid inside a coconut?A. JuiceB. MilkC. WaterD. Oil答案:C。
2014-2015各次C++上机实验报告答案(全)实验__1__①实验报告一、实验目的1.熟悉Visual studio 6.0集成开发环境;2.学习新建和打开控制台应用程序的方法;3.通过运行示例程序了解程序开发过程;二、实验任务1.新建源程序文件,编辑以下程序,编译,链接,得出运行结果,并保存程序:#include <iostream>using namespace std;void main( ){ cout<<'a'<<endl;/*输出语句*/cout<<'\141'<<endl;cout<<'\x61'<<endl;}2.新建源程序文件,编辑以下程序,编译,链接,运行,输入36和64,得出运行结果,并保存程序:#include <iostream>using namespace std;int main(){ float num1,num2,sum;cout << "Enter first number: ";/*输出语句*/cin >> num1; /*输入语句*/cout << "Enter second number: ";cin >> num2; /*输入语句*/sum=num1+num2; /*运算语句*/cout << "The sum is " << sum << endl; /*输出语句*/return 0;}三、实验结果1.2.实验一②实验报告一、实验目的1.熟悉C++程序的集成开发环境;2.学习新建和打开控制台应用程序的方法;3.掌握简单数据运算以及输入与输出方法。
二、实验任务1.输入一个摄氏温度,输出并显示转换出的华氏温度(提示:摄氏温度=(华氏温度—32)*5/9);2.画出一头威武雄壮的雄狮。
第1题:(单项选择题,本题1分)面向对象方法中,实现对象的数据和操作结合于统一体中的是()。
A. 结合B. 封装C. 隐藏D. 抽象正确答案:B答题信息:A答疑:【解析】对象的基本特点是:标识唯一性、分类性、多态性、封装性、模块独立性好。
封装是指隐藏对象的属性和实现细节,将数据和操作结合于统一体,仅对外提供访问方式,B选项正确。
第2题:(单项选择题,本题1分)在进行逻辑设计时,将E-R图中实体之间联系转换为关系数据库的()。
A. 关系B. 元组C. 属性D. 属性的值域正确答案:A答题信息:A答疑:【解析】E-R图中实体之间的联系转换为关系数据库的关系,A选项正确。
第3题:(单项选择题,本题1分)线性表的链式存储结构与顺序存储结构相比,链式存储结构的优点有()。
A. 节省存储空间B. 插入与删除运算效率高C. 便于查找D. 排序时减少元素的比较次数正确答案:B答题信息:C答疑:【解析】顺序表和链表的优缺点比较如下表:由表中可以看出链式存储插入与删除运算效率高,故B选项正确。
第4题:(单项选择题,本题1分)深度为7的完全二叉树中共有125个结点,则该完全二叉树中的叶子结点数为()。
A. 62B. 63C. 64D. 65正确答案:B答题信息:答疑:【解析】在树结构中,定义一棵树的根结点所在的层次为1,其他结点所在的层次等于它的父结点所在的层次加1,树的最大层次称为树的深度。
完全二叉树指除最后一层外,每一层上的结点数均达到最大值,在最后一层上只缺少右边的若干结点。
深度为6的满二叉树,结点个数为2^6-1=63,则第7层共有125-63=62个叶子结点,分别挂在第6层的左边62个结点上,加上第6层的最后1个叶子结点,该完全二叉树共有63个叶子结点,故B选项正确。
第5题:(单项选择题,本题1分)下列叙述中正确的是()。
A. 所谓有序表是指在顺序存储空间内连续存放的元素序列B. 有序表只能顺序存储在连续的存储空间内C. 有序表可以用链接存储方式存储在不连续的存储空间内D. 任何存储方式的有序表均能采用二分法进行查找正确答案:C答题信息:C答疑:【解析】“有序”是特指元素按非递减排列,即从小到大排列,但允许相邻元素相等,A选项错误。
小学上册英语第二单元暑期作业(有答案)英语试题一、综合题(本题有100小题,每小题1分,共100分.每小题不选、错误,均不给分)1.My mom is a ______. She helps us with homework.2.The _____ (露水) in the morning helps hydrate the plants.3.The ______ (花瓣的颜色) can signal to pollinators.4.The cat climbed up the ______.5.The main function of lipids is to store _____.6.The boy likes ________.7.The ________ is a tiny creature that makes music.8.The squirrel collects _______ (坚果) in the fall.9.The train travels ________ the city.10.We have ______ (一个) fun day at the amusement park.11.The __________ (历史的构成) is made up of many elements.12.The ocean is very _______ (广阔的).13.My family travels to ______ (不同的) places.14.The ________ is a joyful little animal.15.Many cultures celebrate the __________ (植物的生长季节).16.What is the name of the famous American author who wrote "To Kill a Mockingbird"?A. Harper LeeB. F. Scott FitzgeraldC. Ernest HemingwayD. Mark Twain答案:A17.The ________ is a famous ancient structure in India.18. A ________ (水獺) loves to swim and catch fish.19.The main gas produced in respiration is _____.20.My hamster runs on its _______ (运动) wheel.21.The first African American to serve as president was _______ Obama.22.The balloons are ___ (floating) in the air.23.In a biochemical reaction, enzymes act as biological _____ to speed up the reaction.24.My birthday is in _______ (九月).25. A chemical reaction can change the properties of ______.26.The cat is ______ on the couch. (sitting)27.The _______ (海豚) is very friendly.28.The girl is very ________.29.The __________ (分子量) is the sum of the atomic weights of all atoms in a molecule.30.I enjoy playing with my ________ (玩具名称) outside.31.What do we call the study of plants?A. BiologyB. BotanyC. ZoologyD. Ecology答案:B.Botany32.Acids tend to turn blue litmus paper _____.33.We write with a ___. (pen)34.My ________ (玩具) is made of eco-friendly materials.35.Astronomical observations have been made for thousands of ______.36.I find ________ (心理学) fascinating.37.The _____ (bicycle/car) is fast.38. A ________ (植物研究支持) fosters innovation.39.The manatee is often called a sea ________________ (牛) due to its gentle nature.40.__________ (表面张力) affects how liquids behave in different environments.41.The _____ (小动物) find shelter among the plants.42.The weather is _______ for a picnic.43.The process of breaking down food in our bodies releases _____.44.The _____ is the force that keeps the planets in orbit.45.The duckling follows its _______ (母亲) everywhere.46.The ________ (discussion) promotes understanding.47.I think it’s important to ________ (关心他人).48.What do you call the action of making a decision?A. DecidingB. ChoosingC. SelectingD. Picking答案: A49.The kids are _____ in the classroom. (talking)50.My mom enjoys __________ on weekends. (购物)51.I enjoy _______ (与家人一起)过周末.52.I enjoy going ________ (跑步) in the morning.53. A ______ (蜥蜴) can be green or brown.54.What do we call the distance around a circle?A. RadiusB. DiameterC. CircumferenceD. Area答案:C. Circumference55.The _____ (teacher/student) is helpful.56.I like to play ________ (排球) with my classmates.57.The __________ (非洲殖民时期) changed many countries.58.The girl sings very ________.59.I use my __________ (玩具名) to help me __________ (动词).60.We are going to the ___. (park)61.The _______ (小果子狸) has a long tail and is very agile.62.I like to collect __________ (玩具名) from different __________ (国家).63.I love to _______ (draw) pictures.64.What is the name of the famous landmark in Egypt?A. Great PyramidB. ColosseumC. Taj MahalD. Stonehenge答案: A65.My friend is very __________ (有耐心).66.The celestial sphere is useful for visualizing ______.67.The ________ (兰花) is a beautiful flower that comes in many colors.68.The ______ is the part of the plant that absorbs sunlight.69.The capital of Germany is __________.70.My brother is very ________.71. A period in the periodic table represents elements with the same number of ______.72. A chemical reaction that produces light and heat is called a ______ reaction.73.The balloon is ______ (yellow) and orange.74.They are friends from ________ (学校).75. A ______ is an animal that can be found in wetlands.76. A ______ (蜜蜂) moves from flower to flower gathering nectar.77.The __________ helps to shape the planet's climate.78.What is the capital of Jamaica?A. KingstonB. Montego BayC. Ocho RiosD. Mandeville答案:A.Kingston79.I have a toy _______ that dances and sings catchy tunes.80.I have a ______ of crayons. (box)81.How many wheels does a bicycle have?A. TwoB. ThreeC. FourD. Five答案:A82. A chemical equation uses symbols to represent a _____.83.What do we call a person who studies the relationship between biology and culture?A. Biocultural AnthropologistB. SociologistC. AnthropologistD. Historian答案: A84. A _______ can be a great project for kids.85. A wave can travel through solids, liquids, and ______.86.The monkey is ________ in the tree.87.The __________ is known for its historical significance.88. A chameleon can change to match its ________________ (环境).89.Burning wood produces __________.90.We have fun playing with ________ (玩具名称).91.The cat caught a ______.92.I love to help my parents ______.93.I enjoy watching a _______ (小金鱼) swim in its bowl.94.The chemical symbol for silver is ______.95. A ______ is a homogeneous mixture of two or more substances.96.Electrons are negatively charged ______ in an atom.97.The _____ (青蛙) has smooth skin and long legs.98.I love ________ with my family.99.The __________ is a region known for its beautiful beaches.100.The chemical formula for sodium bicarbonate is ______.。
第1章 C语言概述1-1编写程序,在屏幕上显示一个如下输出:1-2---------------------------------1-3Programming in C is fun!1-4I love C language.1-5---------------------------------1-6编写程序,在屏幕上显示一个如下图案:1-7* * * *1-8* * *1-9* *1-10*1-11已知某个圆的半径,编写一个程序,用来计算并显示面积。
1-12要求:将π定义为符号常量,并假设一个恰当的半径值。
OutputThe area of circle is: 78.50 1-13已知两个整数20和10,编写程序,自定义函数add( )将这两个数相加,自定义函数sub( )计算这两个数的差,并按照下面形式显示计算结果: 1-1420+10=30 1-1520-10=10Output20 + 10 = 30 20 – 10 = 10 1-16 已知变量a 、b 和c 的值,编写程序,用来计算并显示x 的值,其中cb a -=x 1-17 请分别用以下数值运行该程序 1-18 (1)a=250,b=85,c=25 1-19(2)a=300,b=70,c=80Output (1)x = 4.17Output (2)x = -30.00第2章 常量、变量及数据类型 & 第3章 运算符和表达式3-1 编写程序,求华氏温度100o F 对应的摄氏温度。
计算公式如下: 3-29)32(5-⨯=f c 3-3 式中:c 表示摄氏温度,f 表示华氏温度。
(c 定义为实型,f 定义为整型)OutputCelsius degree (corresponding to 100 Fahrenheit) is: 37.78.3-4 一个物体从100m 的高空自由落下,编写程序,求它在前3s 内下落的垂直距离。
实验一上机操作初步(2学时)一、实验方式:一人一机二、实验目的:1、熟悉VC++语言的上机环境及上机操作过程。
2、了解如何编辑、编译、连接和运行一个C程序。
3、初步了解C程序的特点。
三、实验内容:说明:前三题为必做题目,后两题为选做题目。
1、输出入下信息:(实验指导书P79)*************************Very Good*************************2、计算两个整数的和与积。
(实验指导书P81)3、从键盘输入一个角度的弧度值x,计算该角度的余弦值,将计算结果输出到屏幕。
(书P3)4、在屏幕上显示一个文字菜单模样的图案:=================================1 输入数据2 修改数据3 查询数据4 打印数据=================================5、从键盘上输入两个整数,交换这两个整数。
四、实验步骤与过程:五、实验调试记录:六、参考答案:1、#include <stdio.h>void main( ){ printf(“********************\n”);printf(“ Very Good\n”);printf(“********************\n”);}2、#include <stdio.h>void main( ){ int a,b,c,d;printf(“Please enter a,b:”);scanf(“%d,%d”,&a,&b);c=a+b; d=a*b;printf(“%d+%d=%d\n”,a,b,c);printf(“%d*%d=%d\n”,a,b,d);}3、#include <stdio.h>#include <math.h>void main( ){ double x,s;printf(“Please input value of x:”);scanf(“%lf”,&x);s=cos(x);printf(“cos(%lf)=%lf\n”,x,s);}4、#include <stdio.h>void main( ){ printf(“==================================\n”); printf(“ 1 输入数据 2 修改数据\n”);printf(“ 3 查询数据 4 打印数据\n”);printf(“===================================\n”);}5、#include <stdio.h>void main( ){ int x,y,t;printf(“Please enter x and y:”);scanf(“%d%d”,&x,&y);t=x; x=y; y=t;printf(“After swap:x=%d,y=%d\n”,x,y);}实验二简单的C程序设计(4学时)一、实验方式:一人一机二、实验目的:1、掌握C语言的数据类型。
姓名:______________________学号:______________________专业:______________________日期:______________________指导原则:促进学生针对实际问题,用所学C语言知识编写符合规范的源程序代码,在某一集成开发环境下尽一切调试技能调试程序,并对运行结果进行分析处理,得出正确结论,解决好实际问题。
更快更好地掌握所学知识,技能和软件的一向开发方法目的:1,通过上机实验,加深对教材内容的理解,特别是一些语法规定,熟练掌握各种语法规则。
2,通过上机实验,熟悉某个C语言集成开发环境。
掌握集成开发环境下程序的编辑、编译与连接、运行的完整过程3,通过上机实验,要学会调试程序。
能根据系统给出的“出错信息”,判断错误所在,并修改错误,使程序正确运行。
要求:1,复习与本次实验相关的教学内容2,了解集成开发环境的操作步骤3,准备好实验内容。
对于编程题,一定要自己动手,书写工整,并人工检查无误后才能上机实验,以提高上机效率。
4,要准备好调试和运行程序时所需的数据。
5,对运行中可能出现的问题事先作出估计,并对程序中有疑问的地方作上标记,以便在运行时给予注意。
并在程序调试时,把系统给出的出错原因,解决方法等记载在源程序之后;程序运行结束后,把运行结果也记录下来。
6,每个实验应独立完成,对实际问题所编写的源程序需写出完整实验的报告。
第一次上机作业熟悉C语言集成开发环境实验目的:1,熟悉C语言集成开发环境2,掌握集成开发环境下文件的编写与调用,源程序的编译与调试,程序运行结果的观察与分析。
3,掌握C语言程序的基本结构实验要求:1,程序编写完后,要对输入的每一个符号和词进行检查核对,不能有错。
2,编写源程序时,不要在中文输入法下进行,也不要有首字符大写,否则调试时,会有错误。
实验内容:1,在D盘新建文件夹:D : \C语言程序XXX(所在班级如0709401) XXX(自己学号或姓名如01),作为以后所做程序的存放位置。
第一次上机作业(2014):要求:⏹独立完成,上机调试通过后上交⏹作业提交邮箱:⏹邮件主题命名:班级学号姓名(第1次作业),例如:电1301班2王鹏(第1次作业)⏹以附件形式将每次作业的所有程序源程序压缩打包后提交,压缩文件命名格式同上。
⏹程序必须采用缩进格式1.大写字母转换成小写字母从键盘输入一个大写英文字母,输出相应的小写字母。
例:输入G输出g2.求平方根输入一个实数x,计算并输出其平方根(保留1 位小数)。
例:输入17输出The square root of 17.0 is 4.13.温度转换设计一个程序将华氏温度转换成摄氏温度c = 5/9(f-32)a)输入华氏温度(实型)b)输出的摄氏温度结果保留两位小数例:Please input Fahrenheit temperature: 76.8The corresponding Celsius temperature is 24.894. 计算旅途时间输入二个整数time1 和time2,表示火车的出发时间和到达时间,计算并输出旅途时间。
(输入的有效的时间范围是0000 到2359,不需要考虑出发时间晚于到达时间的情况。
)例:输入712 1411 (出发时间是7:12,到达时间是14:11)输出The train journey time is 6 hours 59 minutes.5. 数字加密输入一个四位数,将其加密后输出。
方法是将该数每一位上的数字加9,然后除以10 取余,做为该位上的新数字,最后将第1 位和第3 位上的数字互换,第2 位和第4 位上的数字互换,组成加密后的新数。
例:输入1257输出The encrypted number is 4601思考题:你能否编程找出谁做的好事?有四位同学中的一位做了好事,不留名,表扬信来了之后,校长问这四位是谁做的好事。
⏹A说:不是我。
⏹B说:是C。
⏹C说:是D。
⏹D说:他胡说。
已知三个人说的是真话,一个人说的是假话。
第十五周作业答案15-1填空题(1)将波长为λ的平行单色光垂直投射于一狭缝上,若对应于衍射图样的第一级暗纹位置的衍射角的绝对值为θ,则缝的宽度等于________________.[答案:/sin λθ]解:sin ,/sin a a θλλθ=∴=(2)波长为λ的单色光垂直入射在缝宽a =4λ 的单缝上.对应于衍射角=30°,单缝处的波面可划分为______________个半波带。
[答案:4] 解:sin 4sin 3042a λθλ==⨯(3)在夫琅禾费单缝衍射实验中,当缝宽变窄,则衍射条纹变 ;当入射波长变长时,则衍射条纹变 。
(填疏或密)[答案:变疏,变疏] 解:1k k fl x x a λ+=-=(4)在单缝夫琅禾费衍射实验中,设第一级暗纹的衍射角很小,若钠黄光(λ1=589nm )中央明条纹为 4.0nm ,则λ2=442nm(1nm=10-9m )的蓝紫色光的中央明纹宽度为 nm 。
[答案:3.0nm ] 解:中央明纹宽度为02f l a λ=,故00442 4.0 3.0589l l nm λλ==⨯=蓝紫蓝紫钠黄钠黄 (5)在透光缝数为N 的平面光栅的衍射实验中,中央主极大的光强是单缝衍射中央主极大光强的 倍,通过N 个缝的总能量是通过单缝的能量的 倍。
[答案:N 2,N ]15-2选择题(1)在夫琅禾费单缝衍射实验中,对于给定的入射单色光,当缝宽度变小时,除中央亮纹的中心位置不变外,各级衍射条纹[ ](A) 对应的衍射角变小.(B) 对应的衍射角变大.(C) 对应的衍射角也不变.(D) 光强也不变.[答案:B](2)波长λ=500 nm (1nm=10-9m )的单色光垂直照射到宽度a=0.25mm 的单缝上,单缝后面放一凸透镜,在凸透镜的焦平面上放置一屏幕,用以观测衍射条纹。
今测得屏幕上中央明条纹一侧第三个暗条纹和另一侧第三个暗条纹之间的距离为d=12mm ,则凸透镜的焦距是[ ](A)2m. (B)1m. (C)0.5m. (D)0.2m. (E)0.1m[答案:B]解: 3610sin tan 3a a a fθθλ-⨯≈== 33396102100.25101m 350010a f λ----⨯⨯⨯⨯===⨯ (3)波长为λ的单色光垂直入射于光栅常数为d 、缝宽为a 、总缝数为N 的光栅上.取k=0,±1,±2....,则决定出现主极大的衍射角θ 的公式可写成[ ](A) N a sin θ=k λ. (B) a sin θ=k λ.(C) N d sin θ=k λ. (D) d sin θ=k λ.[答案:D](4)设光栅平面、透镜均与屏幕平行。
计算机二级考试C++上机考试试题及答案计算机二级考试C++上机考试试题及答案为了使广阔考生在备战计算机等级考试时,更快的把握相应学问点,下面是我搜寻整理的计算机二级考试C++上机考试试题及答案,供参考练习,预祝考生们考出自己抱负的成果!计算机二级考试C++上机考试试题一、程序改错题使用VC++6.0打开考生文件夹下的源程序文件1.cpp,使其输出结果为:n=0留意:不要改动main函数,不能增加或删除行,也不能更改程序的结构,错误的语句在//******error******的下面。
试题程序:#include//********error*******。
classTC(){第1页/共12页public://********error********void~TC(){}TC(intn){cout’n’’=’ };//********error********}voidmain(){TCtest(0);return;}二、简洁应用题使用VC++6.0打开考生文件夹下的源程序文件2.cpp。
请完成函数fun(char*str,charch)的定义,本函数采纳二分法,在已按字母次序从小到大排序的字符数组str中,查找字符ch,若ch在数组中,第2页/共12页函数返回字符ch在数组中的下标,否则返回1。
二分法查找的思想是初始查找区间的下界为0,上界为len-1,查找区间的中部后,k=(下界+上界)/2;若list[k]等于ch,查找胜利;若list[k]ch,则新的查找区间的下界不变,上界改为k-1;否则新的查找区间的下界改为k+1,上界不变。
在新区间内连续用二分法查找。
留意:请勿改动主函数main与其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。
试题程序:#include(iostream.hintfun(char*str,charch){}voidmain(){charstr[]={’a’,’b’,’C’,’d’,’e’,’f’,’9’,’h’,’i,’j’,’k’);charch;第3页/共12页cout请输入一个字符: cinch;cout输入字符的位置是: return;}三、综合应用题使用VC++6.0打开考生文件夹下的源程序文件3.cpp,阅读下列程序说明和代码,功能如下:从屏幕输入数字,然后由大到小插入到指定的链中。
中国石油大学c语言上机题答案大全(2013版)最全最详细1.1 Hello world.让我们用C语言向世界问好。
最早的程序基本是这个样子的:程序一:#include <stdio.h>void main(){printf("Hello world.\n");}程序二:#include <stdio.h>int main(){printf("Hello world.\n");return 0;}上面的程序你任意模仿一个,看看是否可以通过?如果你能通过这个简单的程序,那就让我们继续完成后面的习题吧。
输入:无输出:Hello world.#include<stdio.h>int main(){printf("Hello world.\n");}1.2 Welcome to Beijing.让我们来练习如何显示多行文字。
输入:无输出:就是下面的那段文字。
#include<stdio.h>void main(){printf("Welcome\n");printf("to\n");printf("Beijing.\n");}1.3 练习最简单的printf和scanfprintf函数和scanf函数是C语言中最常用的函数之一,下面让我们练习一下吧。
输入:整型变量x的值。
输出:输出整型变量x对应的十进制、八进制和十六进制形式。
认真观察-1的八进制和十六进制输出,请想想是为什么。
#include <stdio.h>int main(){int x;scanf("%d",&x);printf("x=%d,",x);printf("x=%o,",x);printf("x=%x\n",x);return 0;}1.4 练习两个整数之间的运算背景:基本练习。
小学上册英语第6单元全练全测(含答案)考试时间:100分钟(总分:100)A卷一、综合题(共计100题共100分)1. 选择题:What do we call the act of making a plan?A. OrganizingB. PlanningC. StrategizingD. Arranging2. 填空题:I love to explore the ________ (城市) with my family.3. 选择题:What is the main material used to make paper?A. WoodB. PlasticC. MetalD. Glass答案:A4. 选择题:What do we call the large body of fresh water surrounded by land?A. OceanB. SeaC. LakeD. River答案:C5. 听力题:Oxidation is the loss of _____ (electrons) during a chemical reaction.6. 选择题:What do you call a place where you can borrow books?A. Grocery storeB. LibraryC. ParkD. Museum答案: B7. 选择题:What do you call a solid that has no definite shape?A. LiquidB. GasC. SolidD. Plasma答案:A8. 听力题:The ________ is a natural barrier that protects a coastline.9. 听力题:A __________ is a mixture of gases that can be separated.10. 听力题:The __________ is a narrow body of water between two pieces of land.11. 填空题:I enjoy reading _______ (故事书) before going to _______ (睡觉).12. 填空题:A sunny day makes me want to go ______ (散步).13. 选择题:What is the name of the famous battle fought in 1776?A. Battle of Bunker HillB. Battle of SaratogaC. Battle of YorktownD. Battle of Gettysburg答案: A14. (Civil) War was fought over issues like slavery and states' rights. 填空题:The ____15. 选择题:What do you call a person who studies the Earth?A. GeographerB. GeologistC. MeteorologistD. Biologist答案:AI enjoy _____ (散步) in the park.17. 填空题:My dad is a great __________ (听众) when I talk.18. 填空题:My cousin is an amazing __________ (舞者).19. 选择题:What is the name of the famous wizard in the Harry Potter series?A. GandalfB. DumbledoreC. MerlinD. Harry Potter答案:D20. 听力题:The _______ of light can create various effects in nature.21. 选择题:What do we call a house for fish?A. TankB. PondC. AquariumD. Sea答案:C22. 填空题:The __________ was a major event in the history of the United States. (内战)23. 听力题:The Earth's surface is shaped by both ______ and natural forces.24. 填空题:The __________ (绿叶) produce oxygen for us to breathe.25. 填空题:The __________ (科学发现) inform future generations.26. 填空题:The _____ (农作物轮作) improves soil health.27. 听力题:A convex mirror produces a ______ (virtual) image.What is the name of the famous American author known for writing about the Civil War?A. Walt WhitmanB. Louisa May AlcottC. Mark TwainD. All of the above答案:D29. 填空题:The ancient Maya developed a complex ________ (日历).30. 选择题:What do bees make?A. MilkB. HoneyC. BreadD. Cheese答案:B31. trial Revolution changed how goods were ________ (生产). 填空题:The Indu32. 听力题:Chemical reactions can be affected by _____, concentration, and surface area.33. 听力题:The ice cream truck is ______ (stopping) at the corner.34. 听力题:I enjoy ________ in the summer.35. 听力题:The ________ (committee) makes decisions.36. 听力题:The main gas in Earth's atmosphere is ______.37. 填空题:The _______ (The New Deal) implemented programs to aid recovery during the Great Depression.38. 选择题:What do you call a baby cat?A. PuppyB. KittenC. CubD. Calf答案:B39. 听力题:The __________ is the area where fresh water meets salt water.40. 听力题:We are going to ______ a party for her birthday. (have)41. 选择题:What is 4^2 (4 squared)?A. 8B. 12C. 16D. 20答案:C42. 听力题:The book is ________ the shelf.43. 选择题:What is the name of the fairy tale character who leaves a glass slipper?A. Snow WhiteB. CinderellaC. RapunzelD. Sleeping Beauty答案:B44. 填空题:My sister enjoys learning new ____.45. 听力题:A _______ is a reaction that releases heat.46. 听力题:The chemical formula for arsenic trioxide is _______.47. 选择题:Which animal can fly?A. ElephantB. DogC. BirdD. Fish答案:CThe __________ (天气预报) predicts rain tomorrow.49. 填空题:The __________ (种植时间) is important for success.50. 听力题:The corn is ___ (growing) tall.51. 听力题:The burning of fuels is an example of a _____ reaction.52. 填空题:I want to learn how to _______.53. 听力题:The girl is very ________.54. 选择题:Which fruit is red and often mistaken for a vegetable?A. BananaB. StrawberryC. TomatoD. Grape55. 听力题:The girl is very ________.56. 选择题:What do we call the study of life in the oceans?A. Marine BiologyB. OceanographyC. Aquatic ScienceD. All of the above答案:D57. 选择题:Which insect produces silk?A. AntB. FlyC. ButterflyD. Silkworm58. 听力题:I like to _____ (play) chess.What is 3 x 3?A. 6B. 7C. 8D. 9答案:D60. 听力题:A __________ is a reaction that involves the transfer of electrons.61. 选择题:What is the tallest mountain in North America?A. Mount RushmoreB. Mount DenaliC. Mount RainierD. Mount Hood62. 选择题:What do you call the process of plants making food?A. RespirationB. PhotosynthesisC. DigestionD. Evaporation答案: B63. 听力题:The _____ (grass/sand) is green.64. 听力题:A base can neutralize an _______.65. 填空题:Many __________ (城市) have parks for relaxation.66. 填空题:I enjoy reading books with my ____.67. 填空题:I have a toy _____ that makes music.68. Carta paved the way for modern ________ (民主制度). 填空题:The MagnExploring the world of plants can lead to a greater appreciation for ______. (探索植物的世界可以加深对自然的欣赏。
【C++PrimerPlus】编程练习答案——第15章 1// chapter15_1_tvremote.h23 #ifndef LEARN_CPP_CHAPTER15_1_TVREMOTE_H4#define LEARN_CPP_CHAPTER15_1_TVREMOTE_H5class Remote;6class Tv {7private:8int state;9int volume;10int maxchannel;11int channel;12int mode;13int input;14public:15 friend class Remote;16enum {OFF, ON};17enum {MinVal, MaxVal = 20};18enum {Antenna, Cable};19enum {TV, DVD};2021 Tv(int s = OFF, int mc = 125) : state(s), volume(5), maxchannel(mc), channel(2), mode(Cable), input(TV) {}22void onoff() {state = (state == ON)? OFF : ON;}23bool ison() const {return state == ON;}24bool volup();25bool voldown();26void chanup();27void chandown();28void set_mode() {mode = (mode == Antenna)? Cable : Antenna;}29void set_input() {input = (input == TV)? DVD : TV;}30void settings() const;31void set_status(Remote & r);32 };3334class Remote {35private:36int mode;37int status; // 常规还是互动模式38public:39 friend class Tv;40enum {Normal, Interacte};4142 Remote(int m = Tv::TV) : mode(m), status(Normal){}43bool volup(Tv & t) {return t.volup();}44bool voldown(Tv & t) {return t.voldown();}45void onoff(Tv & t) {t.onoff();}46void chanup(Tv & t) {t.chanup();}47void chandown(Tv & t) {t.chandown();}48void set_chan(Tv & t, int c) {t.channel = c;}49void set_input(Tv & t) {t.set_input();}50void showstatus() const;51 };525354#endif//LEARN_CPP_CHAPTER15_1_TVREMOTE_H555657// chapter15_1_tvremote.cpp5859 #include "chapter15_1_tvremote.h"60 #include <iostream>6162bool Tv::volup() {63if (volume < MaxVal) {64 ++ volume;65return true;66 }67return false;68 }6970bool Tv::voldown() {71if (volume > MinVal) {72 -- volume;73return true;74 }75return false;76 }7778void Tv::chanup() {79if (channel < maxchannel)80 ++ channel;81else82 channel = 1;83 }8485void Tv::chandown() {86if (channel > 1)87 -- channel;88else89 channel = maxchannel;90 }9192void Tv::settings() const {93using namespace std;94 cout << "TV is " << (state == OFF? "OFF" : "ON") << endl;95if (state == ON) {96 cout << "volume setting = " << volume << endl;97 cout << "channel setting = " << channel << endl;98 cout << "mode = " << (mode == Antenna? "antenna" : "cable") << endl;99 cout << "input = " << (input == TV? "TV" : "DVD") << endl;100 }101 }102103void Tv::set_status(Remote &r) {104if (state == ON)105 r.status = r.status == Remote::Interacte? Remote::Normal : Remote::Interacte; 106 }107108void Remote::showstatus() const {109using namespace std;110 cout << "status = " << (status == Interacte? "Interacte" : "Normal") << endl;111 }112113// run114115void ch15_1() {116using namespace std;117 Tv s42;118 cout << "Initial settings for 42\" TV:\n";119 s42.settings();120 s42.onoff();121 s42.chanup();122 s42.chanup();123 cout << "\nAdjusted settings for 42\" TV:\n";124 s42.settings();125126 Remote grey;127 grey.set_chan(s42, 10);128 grey.volup(s42);129 grey.volup(s42);130 cout << "\n42\" settings after using remote:\n";131 s42.settings();132133 Tv s58(Tv::ON);134 s58.set_mode();135 grey.set_chan(s58, 28);136 cout << "\n58\" settings:\n";137 s58.settings();138139 cout << "\n58\" status:\n";140 grey.showstatus();141 s58.set_status(grey);142 grey.showstatus();143 }1// chapter15_2_stdexcept.h23 #ifndef LEARN_CPP_CHAPTER15_2_STDEXCEPT_H4#define LEARN_CPP_CHAPTER15_2_STDEXCEPT_H56 #include <stdexcept>7 #include <cmath>89class meanlogicerr : public std::logic_error {10public:11 meanlogicerr() : logic_error("") {}12const char * what() {return"bad arguments to hmean() or gmean()";}13 };1415#endif//LEARN_CPP_CHAPTER15_2_STDEXCEPT_H1617// run1819double hmean(double a, double b) {20if (a == b)21throw meanlogicerr();22return2.0 * a * b / (a + b);23 }2425double gmean(double a, double b) {26if (a < 0 || b < 0)27throw meanlogicerr();28return std::sqrt(a * b);29 }3031void ch15_2() {32using namespace std;33try {cout << "x = 1, y = 1, hmean = " << hmean(1, 1) << endl;}34catch (meanlogicerr & me) {cout << me.what() << endl;}35try {cout << "x = -1, y = 1, gmean = " << gmean(-1, 1) << endl;}36catch (meanlogicerr & me) {cout << me.what() << endl;}37try {cout << "x = 1, y = 2, hmean = " << hmean(1, 2) << endl;}38catch (meanlogicerr & me) {cout << me.what() << endl;}39try {cout << "x = 1, y = 1, gmean = " << gmean(1, 1) << endl;}40catch (meanlogicerr & me) {cout << me.what() << endl;}41 }1// chapter15_3_meanerr.h23 #ifndef LEARN_CPP_CHAPTER15_3_MEANERR_H4#define LEARN_CPP_CHAPTER15_3_MEANERR_H56 #include <stdexcept>7 #include <iostream>8 #include <string>910class twodouargserr : public std::logic_error {11private:12double arg1;13double arg2;14 std::string funcname;15public:16 twodouargserr(double a1 = 0, double a2 = 0, const char * f = "none")17 : arg1(a1), arg2(a2), funcname(f), std::logic_error("") {}18virtual const char * what() {return"invalid args";}19virtual void msg(){std::cout << funcname << "() logicerr, arg1: " << arg1 << " arg2: " << arg2 << std::endl;} 20 };2122class hmean_err : public twodouargserr {23public:24 hmean_err(double a1 = 0, double a2 = 0, const char * f = "none")25 : twodouargserr(a1, a2, f) {}26virtual const char * what() {return"invalid args";}27virtual void msg(){twodouargserr::msg();}28 };2930class gmean_err : public twodouargserr {31public:32 gmean_err(double a1 = 0, double a2 = 0, const char * f = "none")33 : twodouargserr(a1, a2, f) {}34virtual const char * what() {return"invalid args";}35virtual void msg(){twodouargserr::msg();}36 };373839#endif//LEARN_CPP_CHAPTER15_3_MEANERR_H4041// run4243double hmean2(double a, double b) {44if (a == b)45throw hmean_err(a, b, __func__ );46return2.0 * a * b / (a + b);47 }4849double gmean2(double a, double b) {50if (a < 0 || b < 0)51throw gmean_err(a, b, __func__ );52return std::sqrt(a * b);53 }54void ch15_3() {55using namespace std;56try {cout << "x = 1, y = 1, hmean = " << hmean2(1, 1) << endl;}57catch (hmean_err & he) {cout << he.what() << endl; he.msg();}58try {cout << "x = 1, y = 2, hmean = " << hmean2(1, 2) << endl;}59catch (hmean_err & he) {cout << he.what() << endl; he.msg();}60try {cout << "x = -1, y = 1, gmean = " << gmean2(-1, 1) << endl;}61catch (gmean_err & ge) {cout << ge.what() << endl; ge.msg();}62try {cout << "x = 1, y = 1, hmean = " << gmean2(1, 1) << endl;}63catch (gmean_err & ge) {cout << ge.what() << endl; ge.msg();}64 }剩下的有空写。
上机考试题(1)定义一个学生成绩类Score,描述学生成绩的私有数据成员为学号(No)、姓名(Name[8])、数学(Math)、物理(Phi)、数据结构(Data)、平均分(ave)。
定义能输入学生成绩的公有成员函数Write(),能计算学生平均分的公有成员函数Average(),能显示学生成绩的公有成员函数Display()。
在主函数中用Score类定义学生成绩对象数组s[3]。
用Write()输入学生成绩,用Average()计算每个学生的平均分,最后用Display()显示每个学生的成绩。
实验数据:No Name Math Phi Data Ave1001 Zhou 80 70 601002 Chen 90 80 851003 Wang 70 75 89(2)建立一个存放素数的类Prime,具体要求如下。
①私有数据成员。
"int a[25]:存放指定范围内的所有素数。
int n1,n2:存放指定范围的下限和上限int num:存放素数的个数。
②公有成员函数Prime(int m1,int m2):构造函数,用参数m1、m2初始化n1、n2,同时初始化num。
void primef():求指定范围内的所有素数,把它们依次存放在数组a中。
并将求出的素数个数赋给num。
void show():显示求出的素数的个数及所有的素数,每行输出5个素数。
③在主函数中定义一个Prime类的对象p(100,200),通过p调用成员函数完成求素数及输出素数的工作。
课后习题(1)定义一个复数类Complex,复数的实部Real与虚部Image定义为私有数据成员。
用复数类定义复数对象c1、c2、c3,用默认构造函数将c1初始化为c1=20+40i ,将c2初始化为c2=0+0i,用拷贝构造函数将c3初始化为c3=20+40i。
用公有成员函数Dispaly()显示复数c1、c2与c3 的内容。
!(2)定义一个矩形类Rectangle,矩形的左上角(Left,Top)与右下角坐标(Right,Bottom)定义为保护数据成员。
第一章C++语言概述自测题P21。
1—1 CP8 1。
2-1 形式参数表 1.2-2 main 1。
2—3 ;1。
2-4 } 1.2—5 main 1.2-6 显示器输出流1。
2-7 键盘输入流1。
2—8 头文件 1.2—9 int f( );1.2—10 124 1。
2-11 × 1。
2—12 ×1.2-13 √ 1。
2—14 √ 1.2—15 ×1。
2—16 √ 1。
2-17 ABCFG 1.2-18 D1.2—19 DP11 1。
3—1 OBJ 1。
3—2 source.cpp习题一(P12)1—11.C 2.类型修饰符3.main4.语句以分号(;)结束5.{6.<〈7.〉〉8..h 9.source.obj10.Main 11.char *Hi(const char *); 12.331-21.√2.√3.×4.×5.√6.×7.√8.×1-31.ABFI 2.D 3.ABCD 4.B1—4# include 〈iostream。
h>void main( ){cout <<”C++语言程序设计"<〈endl;}1—5#include <iostream。
h〉void main(){int i,j,k;cout <<"请输入3个整数:";cin 〉>i>>j>>k;cout <<endl〈〈i〈〈”+”<〈j<<”+”〈〈k<〈”=”〈<i+j+k〈<endl;}第二章基本数据类型与表达式自测题P152。
1—1 常量变量 2.1-2 存储格式所能实施的操作P18 2。
2—1 √ 2.2—2 × 2.2-3 8 (常量123456789123L超过了长整型表示的2。
C++Primer第5版第⼗五章课后练习答案练习15.1成员函数应在其声明之前动态绑定。
基类中的虚成员希望其派⽣类定义其⾃⼰的版本。
特别是基类通常应定义虚析构函数,即使它不起作⽤。
练习15.2派⽣类能访问基类的共有成员⽽不能访问私有成员,但派⽣类能访问基类的protected访问运算符描述的成员,⽽禁⽌其它⽤户访问练习15.3#include <string>#include <iostream>#ifndef _QUOTE_H_#define _QUOTE_H_class Quote{public:Quote()=default;Quote(const std::string& book, double sales_price) :bookNo(book), price(sales_price) {}std::string isbn() const { return bookNo; }virtual double net_price(std::size_t n)const { return n * price; }virtual ~Quote() = default;private:std::string bookNo;protected:double price = 0.0;};double print_total(std::ostream& os, const Quote& item, size_t n){double ret = _price(n);os << "ISBN: " << item.isbn() << " # sold: " << n << " total due: " << ret << std::endl;return ret;}#endif// !_QUOTE_H_练习15.4class Base { ... };(a) class Derived : public Derived { ... }; // 错误,类重复定义,不能⾃⼰继承⾃⼰(b) class Derived : private Base { ... }; // 正确(c) class Derived : public Base; // 错误,类的声明包含类名但不包含类派⽣列表练习15.5class Bulk_quote:public Quote{public:Bulk_quote() = default;Bulk_quote(const std::string&, double, std::size_t,double);double net_price(std::size_t)const override;protected:std::size_t min_qty = 0;double discount = 0.0;};Bulk_quote::Bulk_quote(const std::string& book, double p, std::size_t qty,double disc) :Quote(book, p), min_qty(qty), discount(disc) {}inline double Bulk_quote::net_price(std::size_t cnt) const{if (cnt >= min_qty)return cnt * (1 - discount) * price;elsereturn cnt * price;}练习15.6int main(int argc, char* argv[]){Bulk_quote bq;Quote q(bq);print_total(cout, q, 1);print_total(cout, bq, 1);return0;}练习15.7class Limit_quote : public Bulk_quote{public:Limit_quote() = default;Limit_quote(const std::string&, double, std::size_t, std::size_t, double);double net_price(std::size_t)const override;private:std::size_t max_qty = 0;};Limit_quote::Limit_quote(const std::string& book, double p, std::size_t min, std::size_t max,double disc) :Bulk_quote(book, p,min,disc), max_qty(max){}inline double Limit_quote::net_price(std::size_t cnt) const{if(cnt>=max_qty)return max_qty * (1 - discount) * price+(cnt- max_qty)*price;else if (cnt >= min_qty)return cnt * (1 - discount) * price;elsereturn cnt * price;}练习15.8静态类型:在编译时总是已知的,它是变量声明时的类型或表达式⽣成的类型动态类型:变量或表达式表⽰的内存中的对象的类型。
15-1.c 编程题#include<stdio.h>typedef struct s{ long id;char name[10];char sex[2];}PS;int delete(PS *p1, int m, PS *p2,int n) ;int merge(PS *p1,int m, PS *p2 ,int n) ;void sort(PS *p,int n);void display(PS *p,int n);main(){ FILE *fp=fopen("d:\\person.txt","w");PS a[5]={{101, "tom","m"},{103,"mary","f"}, {104,"mark","m"}, {105,"julia","f"}, {106, "sara","f"}},b[10]={{102, "mark","m"}, {104,"mark","m"}};int anum=5,bnum=2,i;anum=delete(a,anum,b,bnum);puts("\n a array:"); display(a,anum);bnum=merge(b,bnum,a,anum);puts("\n b array:"); display(b,bnum);sort(b,bnum);puts("\n b: array"); display(b,bnum);for(i=0;i<bnum;i++)fprintf(fp,"\n%-8ld%-10s%3s",b[i].id,b[i].name,b[i].sex);fclose(fp);}int delete(PS *p1, int m, PS *p2,int n){ int i,j,k;for(i=0;i<m;i++)for(j=0;j<n;j++)if(p1[i].id==p2[j].id){ for(k=i;k<m-1;k++)p1[k]=p1[k+1];m--;}return m;}int merge(PS *p1,int m, PS *p2 ,int n){ int i,j,k;for(i=0;i<n;i++){ for(j=0;j<m;j++)if(p1[j].id>p2[i].id)break;for(k=m;k>=j;k--)p1[k]=p1[k-1];p1[j]=p2[i];m++;}return m;}void sort(PS *p,int n){ PS tmp;int i,j,k;for(i=0;i<n-1;i++)for(j=0;j<n-1-i;j++)if(strcmp(p[j].sex,p[j+1].sex)>0||strcmp(p[j].sex,p[j+1].sex)==0 &&strcmp(p[j].name,p[j+1].name)>0)tmp=p[j],p[j]=p[j+1],p[j+1]=tmp;}void display(PS *p,int n){ int i;printf("ID NAME SEX");for(i=0;i<n;i++)printf("\n%-8ld%-10s%3s",p[i].id,p[i].name,p[i].sex); getch();}15-2.c#include<stdio.h>typedef struct node{ long num;char name[10];struct node *next;}NODE;NODE *create(FILE *fp){ NODE *p1,*p2, *head=NULL;while(!feof(fp)){ p1=(NODE *)malloc(sizeof(NODE));fscanf(fp,"%ld%s",&p1->num,p1->name);if(head==NULL){ head=p1; p2=p1;}else{ p2->next=p1;p2=p1; }}p2->next=NULL;fclose(fp);return head;}void display( NODE *head){if(head==NULL)printf(" The list is empty!");else{ while(head!=NULL){ printf(" %ld %s\n",head->num, head->name); head=head->next;}}}NODE * delete(NODE *head1,NODE *head2){ NODE *p,*p1,*p2;if(head1==NULL||head2==NULL){ printf("List is empty!");return NULL;}p=head2;while(p!=NULL){ p1=head1; p2=p1->next;if(p1->num==p->num) { head1=p2; free(p1);} else{ while(p2->num!=p->num&&p2->next!=NULL){ p1=p2; p2=p2->next;}if(p2->num==p->num){ p1->next=p2->next; free(p2);}}p=p->next;}return head1;}NODE * insert(NODE *head, NODE *newp){ NODE *p1,*p2;newp->next=NULL;if(head==NULL){ head=newp; return head; }if(newp->num < head->num ){ newp->next=head; head=newp;return head;}if(head->next==NULL){ head->next=newp; return head;}p1=head;p2=p1->next;while(newp->num > p2->num && p2->next!=NULL){ p1=p2; p2=p2->next; }if(newp->num > p2->num){ p2->next=newp; newp->next=NULL; }else{ newp->next=p2; p1->next=newp; }return head;}NODE *merge(NODE *head1, NODE *head2){ NODE *p;while(head2){ p=head2;head2=head2->next;head1=insert(head1,p);}return head1;}main(){ FILE *fp1,*fp2;NODE *a_head=0,*b_head=0,*p;clrscr(); /*清屏*/fp1=fopen("c:\\a.txt","r");if(fp1==NULL){printf("can't open file!");return 0;} fp2=fopen("c:\\b.txt","r");if(fp2==NULL){printf("can't open file");return 0;} a_head=create(fp1);puts("\nlist a:");display(a_head);b_head=create(fp2);puts("\nlist b:");display(b_head);fclose(fp1); fclose(fp2);b_head=delete(b_head,a_head);puts("\nlist b:"); display(b_head);a_head=merge(a_head,b_head);puts("\nlist a:");display(a_head);fp1=fopen("d:\\c.txt","w");p=a_head;while(p!=NULL){ fprintf(fp1,"\n %ld %s",p->num, p->name);p=p->next;}fclose(fp1);}15-3.c 改错题#include<stdio.h>#include<conio.h>struct /* 改为:typedef struct */{ char name[10], degree[10];}ST;void sort(ST x[],int n,char key[][10],int m){ int i,j,k,con1,con2;ST v;for(i=0;i<n-1;i++)for(j=0;j<n-i-1;j++){ for(k=0;k<m;k++)if(strcmp(x[j].degree,key[k])==0){ con1=k; break; }for(k=0;k<m;k++)if(strcmp(x[j+1].degree,key[k])==0){ con2=k; break; }if(con1>con2||con1==con2&&strcmp(x[j].name,x[j+1].name)<0)/*改为: strcmp(x[j].name,x[j+1].name)>0 */{ v=x[j]; x[j]=x[j+1]; x[j+1]=v; }}}void main( ){ ST s[5]={{"A","master"},{"B","bachelor"},{"C","doctor"},{"D","bachelor"},{"E","master"}};char sortkey[3]={"bachelor","master","doctor"}; /*改为 sortkey[3][10] */int i;sort(s,5,sortkey,3);for(i=0;i<5;i++)printf("\n%s %s",s[i]->name,s[i]->degree); /* 改为s[i].name,s[i].degree */ getch();}。