动态网站制作指南 [  QQ表情  ]
[ 投票调查 ]
[ 企业邮箱 ]
[ 网站空间 ]
网络编程 | 站长之家 | 网页制作 | 图形图象 | 操作系统 | 冲浪宝典 | 软件教学 | 网络办公 | 邮件系统 | 网络安全 | 认证考试 | 系统进程
ASP源码 | .Net源码 | PHP源码 | JSP源码 | JAVA源码 | CGI源码 | VB源码 | C++源码 | Delphi源码 | PB源码 | VF源码 | 汇编 | 服务器
Firefox | IE | Maxthon | 迅雷 | 电驴 | BitComet | FlashGet | QQ | QQ空间 | Vista | 输入法 | Ghost | Word | Excel | wps | Powerpoint
asp | .net | php | jsp | Sql | c# | Ajax | xml | Dreamweaver | FrontPages | Javascript | css | photoshop | fireworks | Flash | Cad | Discuz!
当前位置 > 网站建设学院 > 网络编程 > C/C++教程
Tag:注入,存储过程,分页,安全,优化,xmlhttp,fso,jmail,application,session,防盗链,stream,无组件,组件,md5,乱码,缓存,加密,验证码,算法,cookies,ubb,正则表达式,水印,索引,日志,压缩,base64,url重写,上传,控件,Web.config,JDBC,函数,内存,PDF,迁移,结构,破解,编译,配置,进程,分词,IIS,Apache,Tomcat,phpmyadmin,Gzip,触发器,socket
网络编程:ASP教程,ASP.NET教程,PHP教程,JSP教程,C#教程,数据库,XML教程,Ajax,Java,Perl,Shell,VB教程,Delphi,C/C++教程,软件工程,J2EE/J2ME,移动开发
文章搜索服务
邮件订阅
输入你的邮件地址,
你将不会错过任何关于:
[ C/C++教程 ]的信息

本月文章推荐
.使用Microsoft Agent的COM接口编.
.C++:最强大的.NET语言之对象构造.
.用栈模拟商店进货系统.
.用BCB开发有身份认证功能的Email.
.Stan Lippman:C++/CLI全景体验(.
.巧算星期几.
.C++习题与解析(重载-03).
.C++代码优化方法(1).
.深度探索C++对象模型(6).
.C++ Builder创建组件探密.
.程序员眼中的qmail(qmail源代码分.
.使用Microsoft Agent的COM接.
.送给初学者的礼物:C++游戏编程起.
.利用中断实现每500毫秒接收一次数.
.深入理解C++中的mutable关键字.
.C/C++中命令行参数的原理.
.水滴石穿C语言之指针、数组和函数.
.VC++编程隐藏计算机中的鼠标.
.奇技淫巧C++之语法魔力球.
.Java进阶:JNI使用技巧点滴.

偶写的链表、堆栈、队列的集合操作

发表日期:2008-3-8 |


偶写了一个程序,它的功能是将链表、堆栈、和队列进行集合操作,可以处理一般的插入N个元素,删除N个元素,以及入栈出栈的问题。
--------本程序的最大的特点是能够准确的显示当前的集合操作的各个元素的状态,并且能够将队列的数据以堆栈的格式输出,同样也支持将堆栈的数据以队列的格式显示出来,报错功能也不错,程序的最后将我们开辟的所有的结点空间全部释放掉。 偶觉得,数据结构,说白了就是个哪个先进哪个先出的问题,大家觉得呢?? -----------------偶的QQ:37170732,欢迎喜欢编程的同学加我,非凡是爱好Win32和MFC的同学,大家一起来讨论哦! -----------------------------下面是程序的代码------------------------------------------

#include <stdio.h>
#include <conio.h>
#define NULL 0
typedef int DataType;
typedef strUCt Node *PNode;
struct Node
{
  DataType  info;
  PNode link;
};
struct LinkType
{
  PNode base;
  PNode top;
};
typedef struct LinkType *PLinkType;

PLinkType CreatePointer(void)
{ PLinkType pltype;
  pltype=(PLinkType)malloc(sizeof(struct LinkType));
  if(pltype== NULL) { printf("\nOut of space\n");
     pltype=(PLinkType)realloc(sizeof(struct LinkType));}
  pltype->base=pltype->top=NULL;
  return(pltype);
}

PLinkType CreateHeadNode(PLinkType pltype)
{ PNode paque;
  paque=(PNode)malloc(sizeof(struct Node));
  if(paque==NULL){
  printf("Out of space\n");
  paque=(PNode)realloc(sizeof(struct Node));}
  else if(paque!= NULL) pltype->base=pltype->top=paque;
  pltype->top->link->link=NULL;

  return(pltype);
}

PLinkType push_Type(PLinkType pltype,DataType n)
{ PNode p;
  int j;
  j=0;
  printf("Input %d integer:\n",n);
  while(j<n) {
   pltype->top->link=(PNode)malloc(sizeof(struct Node));
   if(pltype->top->link==NULL) {
printf("Out of space");
pltype->top->link=(PNode)realloc(sizeof(struct Node));}
   else { while(pltype->top->link!=NULL){
   pltype->top->link->link=NULL;
   pltype->top=pltype->top->link;
   scanf("%d",&pltype->top->info);
   j++;}}}
 return(pltype);
}

PLinkType print_Type(PLinkType pltype)
{ PNode temp;
  temp=pltype->base;
  if(temp!=pltype->top){
   printf("\n");
   while(temp!=pltype->top) {
 printf("%d\t",temp->link->info);
 temp=temp->link;}}
  else printf("empty");
  return(pltype);
}

PLinkType pop_Type(PLinkType pltype)
{
  while(pltype->base!=pltype->top) {
   printf("%d\t",pltype->base->info);
   pltype->base=pltype->base->link;}
  return(pltype);
}

PLinkType de_Type(PLinkType pltype, DataType j)
{int i;
 i=0;
 if(pltype->base!=pltype->top){
    printf("The pop type list is:\n");
    while(pltype->base!=pltype->top &&i<j){
   printf("%d\t",pltype->base->link->info);
   pltype->base=pltype->base->link;
   i++;}
    printf("\n%d number(s) has been detyped",i);}
 if(pltype->base==pltype->top){
    printf("\nAll the type have been detyped");}
 return(pltype);
}

PLinkType pop_Stack(PLinkType pltype,DataType j)
{PNode temp;
 int i;
 i=0;
 if(pltype->top!=pltype->base){
   printf("The pop stack is:\n");
   while(pltype->top!=pltype->base &&i<j){
   temp=pltype->base;
   if(temp->link!=pltype->top){
    while(temp->link != pltype->top) temp=temp->link;
    pltype->top->link=pltype->top;
    pltype->top=temp;
    printf("%d\t",pltype->top->link->info);
    i++;}
 else{pltype->top->link=pltype->top;
      pltype->top=temp;
      printf("%d\t",pltype->top->link->info);
      i++;}}
 printf("\n%d number(s) have been poped\n",i);
   return(pltype);}
 return(pltype);
}

PLinkType free_all(PLinkType pltype)
{PNode temp;
 while(pltype->base!=pltype->top){
       temp=pltype->top;
       pltype->base=pltype->base->link;
       free(temp);}
 free(pltype->base);
 free(pltype);
 printf("All the Nodes and pointer have been freed\n");
}

void main()
{ PLinkType pltype;
  PNode pastack;
  int j1,j2,j3,j4,j5,k;
  int m1,m2,m3,m4,m5,n1,n2,n3,n4,n5;
  pltype=CreatePointer();
  CreateHeadNode(pltype);
  printf("please choose the type of data struct:\n");
  printf("1:linklist, 2:linkstack,3:linkqueue,0:to exit\n");
  scanf("%d",&k);
  while(k!=0){
  switch(k){
  case 1:{printf("Input the length of linklist:\n");
  scanf("%d",&m1);
  while(m1<1 ){
    printf("The length is illegal,please input again\n");
    scanf("%d",&m1);}
  push_Type(pltype,m1);
  printf("The link list is");
  print_Type(pltype);
  printf("\nIf you want to enlist or delist,please choose\n");
  printf("1: to enlist,  2: to delist,   0:to struct choose\n");
  scanf("%d",&m2);
  while(m2!=0){
  switch(m2){
  case 1:{printf("Input the length of the list\n");
 scanf("%d",&m3);
 while(m3<1 ){
 printf("The length is illegal,please input again\n");
 scanf("%d",&m3);}
 push_Type(pltype,m3);
 printf("The link list is:");
 print_Type(pltype);} break;
  case 2:{if(pltype->base==pltype->top){
  printf("The link list is empty\n");}
 else{
   printf("please input number(s) that you want to delist:\n");
   scanf("%d",&m4);
   de_Type(pltype,m4);
   printf("\nThe&n

上一篇:偶写的链表、堆栈、队列的集合操作------的解释补充 人气:320
下一篇:排序算法比较程序 人气:1005
浏览全部C/C++的内容 Dreamweaver插件下载 常用网页广告代码全集
  最新网站源码 最新软件下载
2008-8-20 25175 学生成绩管理查询系统 v2.
2008-8-20 乘风电影程序 v3.7 Acc
2008-8-20 乘风电影程序 v3.7 Sql
2008-8-20 EasyJForum v2.2
2008-8-20 XML文章系统 v1.08 build 080820
2008-8-20 老Y文章管理系统 v2.0 build 080
2008-8-20 OA企业智能办公自动化系统边缘特
2008-8-20 欣颐免费时尚发廊美发厅全站程序
2008-8-20 凌风简单留言板 v1.0
2008-8-16 iLaba Player(小喇叭播放器) v2.
2008-8-16 DoubleClickFix 鼠标双击修正工具
2008-8-16 CrystalCPUID 4.15.2.451
2008-8-16 VeryCD 电驴(easyMule) 1.0.4 Bu
2008-8-16 uTorrent 1.8 Build 11813 - Sta
2008-8-16 比特精灵(BitSpirit) v3.3.2.287
2008-8-16 StayInTune音叉 v1.0 破解版
2008-8-16 iChing《周易》汉化补丁 v1.0
2008-8-16 Starmap星空图v1.0汉化破解版
  发表评论
姓 名: 验证码:
内 容:
[ 汉字翻译拼音 ] [ 广告代码 ] [ 符号对照表 ] [ 进制转换 ] [ 经典小工具 ] [ 个税计算 ] [ 汉字简繁转换 ] [ 普通单位换算 ] [ 公制单位换算 ]
[ 生辰老黄历 ] [ 国内电话区号 ] [ 国家代码与域名缩写 ] [ 文字加密解密 ] [ 健康查询 ] [ 万年历 ] [ 手机号码查询 ] [ ip搜索 ] [ Google PR查询 ]
业务联系 | 广告刊登 | 频道合作 | 投稿荐稿 | 联系方式 | 加入收藏 | RSS订阅
Copyright © 2000-2008 www.knowsky.com All rights reserved | 网络实名:动态网站制作指南 | 沪ICP备05001343号
ホームページ制作 不動産検索システム 求人情報
防水工事·改修工事 フットサル大会 探偵