东北大学C语言实验报告——数组
C语言程序设计实验报告
实验名称数组学 院资源与土木工程专业班级采矿1201姓 名杨林学 号任课教师柳秀梅实验时间2013年5月14日星期二
实验目的
熟练掌握一维数组、二维数组的定义、初始化和输入、输出方法;
熟练掌握字符数组和字符串函数的使用;
熟练与数组有关的常用算法(如查找、排序等)。
实验内容
设定一个整型数组存放20个元素,采用直接赋值的方法在程序中初始化该数组(假设这些数组已排序);
用scanf函数输入一个要找的数值;
对查找的结果给出相应的说明,如果找到该数值,则输出“Found”信息,并给出该数是数组中的第几个元素。如果该数值不在数组中,则输出“Not found”信息。
算法描述流程图
N
Y
Y
N
N Y
N
Y
源程序
测试数据
测试数据3,5 16
运行结果
当测试数据为3时
当测试数据为5时
当测试数据为16时
出现问题及解决方法
当在数组a[20]中找到输入的数时,无法结束循环,加入break语句后即解决此问题。
实验心得
通过本次实验掌握了折半查找法的基本步骤,能从一个数组中找出所需要的数,并且能熟练运用break语句。
to prevent the accumulation of air, both ends of the tube are required the Center to bake. 6.2.5 sets should be at the bottom 200mm lashing cable head is fixed rung, with a similar cable color of plastic lashings. Cable head using "equal-width stacked" layout, or according to the size and space within the enclosure cable volume adjust, but you must ensure uniform, neat and elegant. 6.2.6 disc cabinet within cable shield layer requirements
to prevent the accumulation of air, both ends of the tube are required the Center to bake. 6.2.5 sets should be at the bottom 200mm lashing cable head is fixed rung, with a similar cable color of plastic lashings. Cable head using "equal-width stacked" layout, or according to the size and space within the enclosure cable volume adjust, but you must ensure uniform, neat and elegant. 6.2.6 disc cabinet within cable shield layer requirements
to prevent the accumulation of air, both ends of the tube are required the Center to bake. 6.2.5 sets should be at the bottom 200mm lashing cable head is f