第001关
结点定义为
Data是数据
Next是指针
把链表的定义完成,纠正这个语法错误。
第002关
输入数据13、21、18、6、48、62、24、20
调试数个错误,直到显示结果为
20
21 6
62
13 18 48
24
然后分别查找20、6、48看看,显示结果
能不能找到
另外你认为有什么问题吗?
另外在报告中写出
1.每次插入新数据时是按照栈还是按照队列的方式挂链的
2.为什么可以不断的输入数据,而不是固定的数据个数
第003关
查找的计数始终不对,怎么办?
程序二:
以下的程序是二分法的递归算法,没有语法或逻辑错误,主要考虑如何集成。如菜单的处理、对象的定义和实现。
对输入数据的相应。
#include "iostream.h"
template <class Type>
int Find(Type * pDatas,int nSmall,int nBig,Type & Data)
{
int mid=(nBig+nSmall)/2;
if(nBig<nSmall)
return 0;
if(*(pDatas+mid)==Data)
return mid+1;
else if(*(pDatas+mid)<Data)
return Find(pDatas,mid+1,nBig,Data);
else
return Find(pDatas,nSmall,mid-1,Data);
}
void main()
{
int number[]={12,34,56,78,91,112,134,151,718,920};
int count=10;
int findData,findPosition;
char choose;
cout<<"A group of ordinal data are the following numbers."<<endl;
cout<<"一组有序的数据如下:"<<endl;
for(int i=0;i<count;i++)
cout<<number[i]<<" ";
cout<<endl;
while(1)
{
cout<<"Please input the data that you want to find. "<<endl;
cout<<"请输入你想要查找的数据:";
cin>>findData;
if(findPosition=Find(number,0,count-1,findData))
{
cout<<"The data "<<findData<<" is found . The Position is the "<<findPosition<<"th."<<endl;
cout<<"数据"<<findData<<"被找到。位置序数是第"<<findPosition<<"个。"<<endl;
}
else
{
cout<<"The data "<<findData<<" isn't found in the group datas."<<endl;
cout<<"在这组数据中找不到数据"<<findData<<"。"<<endl;
}
cout<<"Do you want to continue to test?Yes/No (Y/N) :"<<endl;
cout<<"你想继续测试吗?是/否(Y/N):";
cin>>choose;
if(!(choose=='y'||choose=='Y'))
break;
}
}
程序三:
以下的程序是二分法的循环算法,还有四个错误的地方,需要按照原理重写出来。
#include "iostream.h"
template <class Type>
int Find(Type * pDatas,int nCount,Type & Data)
{
int small=0,big=nCount-1;
//以下语句有错
int mid=***;
while(big>=small)
{
if(*(pDatas+mid)==Data)
//此处有错;
return ***;
else if(*(pDatas+mid)<Data)
//此处有错;
else
//此处有错;
mid=(big+small)/2;
}
return 0;
}
void main()
{
int number[]={12,34,56,78,91,111,114,156,171,192};
int count=10;
int findData,findPosition;
char choose;
cout<<"A group of ordinal data are the following numbers."<<endl;
cout<<"一组有序的数据如下:"<<endl;
for(int i=0;i<count;i++)
cout<<number[i]<<" ";
cout<<endl;
while(1)
{
cout<<"Please input the number that you want to find. "<<endl;
cout<<"请输入你想要查找的数据:";
cin>>findData;
if(findPosition=Find(number,count,findData))
{
cout<<"The data "<<findData<<" is found . The Position is the "<<findPosition<<"th."<<endl;
cout<<"数据"<<findData<<"被找到。位置序数是第"<<findPosition<<"个。"<<endl;
}
else
{
cout<<"The data "<<findData<<" isn't found in the group datas."<<endl;
cout<<"在这组数据中找不到数据 "<<findData<<"。"<<endl;
}
cout<<"Do you want to continue to test?Yes/No (Y/N) :"<<endl;
cout<<"你想继续测试吗?是/否(Y/N):";
cin>>choose;
if(!(choose=='y'||choose=='Y'))
break;
}
}
哈希查找(散列查找)法实验
需积分: 35 100 浏览量
2010-06-09
16:29:31
上传
评论
收藏 12KB RAR 举报
sunnyrain0428
- 粉丝: 1
- 资源: 2
最新资源
- 毕业设计基于STM32的测量温度与压力的数据处理设计C语言完整源码+论文.zip
- 基于MATLAB的PCA算法人脸识别项目源码+GUI界面+说明文档.zip
- 基于STM32的测量温度与压力的数据处理设计源码+论文(毕业设计).zip
- Vision Transformer 网络对不同氨气氧气浓度轨迹RAS 图像数据集的分类,包含训练权重和数据集、迁移学习
- 基于C51带字库LCD12864(ST7920)的keil工程源码,只支持8位并口通讯(不支持串口),可显示中文.zip
- 基于SI4463射频模块433MD-SMA无线模块软硬件技术资料及(SI4463)IC技术资料文档.zip
- (GPS+北斗+GSM)HLK-GS2503模块软硬件开发资料包硬件参考设计(原理图PCB)+技术文档资料.zip
- 基于BERT+Biaffine结构的关系抽取模型源码+文档说明.zip
- 利用c语言编写的冒泡排序代码
- 基于Ansoft-HFSS知识总结hfss中文教程HFSS培训教材等技术资料合集(50个).zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈