05 2014 档案
摘要:/**************************************************************** Name: StuManaMain.cpp* Purpose: Code for Application Frame* Author: Zhangaihua (...
阅读全文
摘要:main.cxx#include "soci.h"#include "soci-sqlite3.h"using namespace soci; #include using namespace std;int main(){session sql;sql.open(sqlite3, "./stu.d...
阅读全文
摘要:main.cxx#include #include #include #include using namespace std; int main() { sqlite3* file; int flag; flag = sqlite3_open("./stu.db", &file); if(...
阅读全文
摘要:以下是学生公寓信息管理的增加和删除,仅供参考。。void StuManaFrame::OnAdd(wxCommandEvent &event){ //add student's dormitory infomation sqlite3 *db=NULL;int flag; char *errms...
阅读全文
摘要:/*************************************************************** * Name: CaculatorMain.h * Purpose: Defines Application Frame * Author: zhangaihua (62...
阅读全文
摘要:判断单链表是否有环两个指针分别为p1和p2,每循环一次只向前走一步,p2向前走两步,知道p2碰到NULL指针或者两个指针相等则说明有环如果存在,start存放在圆环开始的节点bool IsLoop(node *head,node *start){node *p1=head,*p2=head;if(h...
阅读全文
摘要:例:已知两个单链表head1和head2各自有序升序排列,请把他们合并成一个连表并依然有序,并保留原来所有节点
假设以下两个链表:
链表1:1-3-5
链表2:2-4-6
(1)比较1和链表2的第一个节点数据,由于15)和链表2在调用本过程,比较得到结果链表的第二个节点,即2与3比较得到2,此时合并后的链表节点为1-2,这样
递归知道两个链表的节点都被加到结果链表中。
阅读全文
摘要:将单链表逆序单链表的逆置遍历一遍单链表,利用一个辅助指针存储遍历过程中当前指针指向下一个元素,然后将当前元素的指针反转,利用已经存储的指针往后继续遍历node *reverse(node *head){node *p,*q,*r;if(head->next==NULL)//链表为空{return head;}p=head->next;q=p->next;//保存原第二个节点p->next=NULL;//原第一个节点为末节点while(q!=NULL)//遍历各个节点的next指针反转{r=q->next;q->next=p;p=q;q=r;}head->
阅读全文
摘要:单链表节点的删除删除单链表pos位置的节点,返回头指针pos从开始计算,1表示删除head后面的第一个节点node *delete_node(node *head,int pos){node *item=NULL;node *p=head->next;if(p==NULL){printf("link is empty\n");return NULL;}p=search_node(head,pos-1);//获得位置pos的节点指针if(p!=NULL && p->next!=NULL){item=p-...
阅读全文
摘要:单链表节点的插入在单链表中某位置(pos个节点)后面插入节点1.插入到链表首部2.插入到链表中间3.插入到蓝标尾部单链表某个位置插入节点,返回链头指针,pos从0开始计算,0表示插入到head节点后面node *insert_node(node *head,int pos,int data){node *item=NULL;node *p;item=(node *)(sizeof(node));item->data=data;if(pos==0)//插入到链表头后面{head->next=item;return head;}p=search_node(he...
阅读全文
摘要:单链表节点的查找查找单链表pos位置的节点,返回节点指针pos从0开始,0返回head节点node *search_node(node *head,int pos){node *p=head->next;if(posnext)==NULL){printf("incorrect position to search node\n");break;}}return p;}
阅读全文
摘要:计算单链表的长度计算单链表的长度,实现单链表的打印实现单链表的建立链表节点的定义:typedef struct node{int data;//节点内容node *next;//下一个节点}创建单链表node *Create(){int i=0;//链表中数据个数node *head,*p,*q;int x=0;head=(node*)malloc(sizeof(node));//创建头结点while(1){printf("input the data:");scanf("%d",&x);if(x==0)break;//Data为0时创建结束p=
阅读全文
摘要:实现单链表的建立链表节点的定义:typedef struct node{int data;//节点内容node *next;//下一个节点}创建单链表node *Create(){int i=0;//链表中数据个数node *head,*p,*q;int x=0;head=(node*)malloc(sizeof(node));//创建头结点while(1){printf("input the data:");scanf("%d",&x);if(x==0)break;//Data为0时创建结束p=(node*)malloc(sizeof(node
阅读全文
摘要:wxWidgets和Codeblocks的编译安装,GUI程序开发平台的搭建具体步骤如下:(1)基本编译环境安装安装编译工具(gcc之类)sudo apt-get install build-essential安装X11sudo apt-get install libx11-dev安装GTK需要的东西sudo apt-get install?gnome-core-devel(2)下载wxWidgets源码包并解压缩到 #{wxdir}(3)创建基于gtk和x11的编译目录${wx}mkdir ${wx}/buildgtkmkdir ${wx}/buildx11(4)编译wxgtkcd ${wx
阅读全文
摘要:1.#includeusing namespace std;int main(){ coutint main(){int k;char x;cout>k;vector a(k),b(k),c(k);cout>a;cout>b;L:cout>x;switch(x){case '+':c=a+b;break;case '-':c=a-b;break;case '*':c=a*b;break;case 'q':goto Z;default:cout>(istream &input,vector&am
阅读全文

浙公网安备 33010602011771号