
C/C++
文章平均质量分 78
Hugo_scnu
计算机专业IT码农
展开
-
图的遍历
题目 图的遍历 【问题描述】 1、掌握图的数据类型描述及特点。 2、对图分别采用邻接表和邻接矩阵表示,并进行深度遍历和广度遍历。 【实验内容】 该程序开始时是通过用户输入的图的数据文件(.txt)所在的路径来读取对应文件中的图的数据,以此来构建,进而调用遍历算法函数来对图进行遍历,如果文件不存在或路径不正确,程序将会报告错误并终止; 本程序读取的文件的格式是.txt文原创 2013-09-26 21:37:09 · 945 阅读 · 0 评论 -
C++进阶 必读书籍
(一)语言入门:《C++ Primer》最新版本:第三版(第四版国外已上架, 国内一些网上书店也在预订中)适合有丰富C经验,缺乏C++经验的。不过我个人一直认为此书带着过于强烈的C语言的痕迹,对于C++的学习未必是 好事。《The C++ Programming Language》/《C++程序设计语言》最新版本:第三版特别版简称 TC++PL,有其他语言的丰富经验转载 2013-09-28 01:06:45 · 783 阅读 · 0 评论 -
嵌入式学习指南
近些年来,嵌入式系统的发展在国内可谓如火如荼,很多公司都急需嵌入式系统方面的开发人员。然而,在高校中,嵌入式系统的教学却较为滞后,很多高年级的本科生和刚入学的研究生都苦于不知从何学起。在本文中,笔者将根据自己的嵌入式系统开发和教学经验,简要介绍嵌入式系统的学习方法,力求能帮助初学者找到一条入门之路。什么是嵌入式系统? 学习嵌入式系统,首先应该明确什么是嵌入式系统,否则费力去学,却不转载 2013-09-28 01:10:26 · 784 阅读 · 0 评论 -
学生健康表(链表)
#include#include#include#include#includeusing namespace std;struct LinkNode{ struct LinkNode *next; string num;//学号 string name;//姓名 string sex;//性别 string health;//健康状况 string birthday;//出生日原创 2013-09-26 21:36:51 · 2115 阅读 · 0 评论 -
二叉搜索树
#include#includeusing namespace std;templatestruct BSTNode{ //二叉树结点类 E data; //数据域 BSTNode *left,*right;原创 2013-09-26 21:37:03 · 595 阅读 · 0 评论 -
Huffman Code
#include//该程序实验哈夫曼树的建立、编码、译码三个基本功能#include#include#include#includetypedef struct{ //结构体 char ch; //字符 int weight; //权值 int parent,lchild,rchild;}htnode,*hfmtree;typed原创 2013-09-26 21:37:21 · 975 阅读 · 0 评论 -
stack 实现中缀表达式
实验3题目 算术表达式的计算【问题描述】 利用堆栈实现算术表达式的计算【实验内容】 必做内容:运算对象均为整数 选作内容:运算对象扩充为可以是带小数位的浮点数【测试数据】输入格式:一行一个算术表达式,可以输入若干行输出格式:一行一个输出结果样例:输入样例:2*(3 + 4)6+ 2 * 8 /4输出样例1410代码:#include//中缀——>后缀——>计算(不包括括号)#inclu原创 2013-09-26 21:36:47 · 957 阅读 · 0 评论 -
二叉树的基本操作
#include#include#includeenum tag1{L,R};using namespace std;struct BinTreeNode{ char data; BinTreeNode *leftChild,*rightChild;};class BinaryTree{public: BinaryTree():root(NULL){}; //析构函数 void原创 2013-09-26 21:36:57 · 1116 阅读 · 0 评论 -
排序算法(快速排序、直接插入排序、直接选择、冒泡排序)
typedef int T;//冒泡排序算法void BubbleSort(T V[],int n){ bool exchange; int i,j; for(i=1;i { exchange=false;//交换标志 for(j=n-1;j>=i;j--) if(V[j-1]>V[j]) { T temp=V[j-1]; V[j-1]原创 2013-09-26 21:37:06 · 1094 阅读 · 0 评论 -
快速查找
#includeusing namespace std;int Search(int s[],int x,int n){//二分查找的非递归算法 int mid,low=0; int high=n-1; while(low { mid=(low+high)/2; if(x==s[mid]) return mid; else if(x原创 2013-09-26 21:37:16 · 703 阅读 · 0 评论 -
快速排序、归并排序与选择排序平均时间之比较
#include#include#includeusing namespace std; void Merge(int Array[],int TempArray[],int low,int high,int mid); void MergeSort(int Array[],int TempArray[],int low,int high) { int mid; if(low {原创 2013-09-26 21:37:25 · 1700 阅读 · 0 评论 -
The knight\'s tour(马周游问题)
三个策略:1、先从中心点开始走;2、往靠边走;3、对下一步进行评分,低分的先走。/*马周游问题,m*n的棋盘,放置在其上的马能否恰好访问每一个方格一次并回到起始位置深度优先搜索,若寻找到满足要求的解,则输出;否则推回上一层往下一个方向搜索。(非递归)对于当前所在位置(x,y),依次枚举8个方向搜索,直到找到一组可行解为止。使用剪枝有3处:第一、使用Warnsdorff's rule,枚举当前解得时原创 2013-09-26 21:37:30 · 2673 阅读 · 0 评论 -
排序算法
#include//本次排序只针对整型数组有效#includeusing namespace std;const DefaultSize=50;//定义数组的大小void BubbleSort(int V[],int n)//冒泡排序算法{ bool exchange; int i,j; for(i=1;i { exchange=false;//交换标志 for(j=n原创 2013-09-26 21:37:12 · 586 阅读 · 0 评论 -
用动态规划法求解生物信息学中DNA序列比对的问题 (交叉学科应用实验)
#include#include#includeusing namespace std;stack s;//当前搜索路径的LCSstack lcs[100];//所有的LCSint count=0;//记录LCS的数量bool lcs_have_exist(stack lcs[],int count,stack s){//判断当前搜索的LCS是否已存在于 stack_lcs[MAX] int i;原创 2013-09-26 21:37:28 · 5210 阅读 · 0 评论 -
顺序表学生个人健康信息表(数组)
#include#include#include#include#includeconst maxsize=100;int n;//定义要输入数据的个数using namespace std;struct Student{ string num;//学号 string name;//姓名 string born;//出生年月 char sex;//性别 string原创 2013-09-26 21:36:54 · 1442 阅读 · 0 评论 -
二分查找算法(快速查找)
int Search(int s[],int x,int n){//二分查找的非递归算法 int mid,low=0; int high=n-1; while(low { mid=(low+high)/2; if(x==s[mid]) return mid; else if(x high=mid-1; else low=原创 2013-09-26 21:37:00 · 935 阅读 · 0 评论 -
C++ 简单读写文本文件、统计文件的行数、读取文件数据到数组
原文链接:http://hi.baidu.com/ctralt/item/b40106c30f955951ac00ef09fstream提供了三个类,用来实现c++对文件的操作。(文件的创建、读、写)。ifstream -- 从已有的文件读ofstream -- 向文件写内容fstream - 打开文件供读写文件打开模式:ios::in转载 2013-10-30 17:19:26 · 1051 阅读 · 0 评论