没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
infoBook.c
#include "dataStruct.h"
#include <stdio.h>
#include <stdlib.h>
#include <malloc.h>
#include <string.h>
#define MAXSIZE 200
#define SAVEALL 0
#define APPEND 1
void add(list li, node newnd)
{
li->count++;
/*更改插入结点的前后关系*/
node temp = li->top->pre;
li->top->pre = newnd;
newnd->next = li->top;
newnd->pre = temp;
newnd->pre->next = newnd;
}
void order(list li)
{
/*采用插入排序,找到应插入的位置*/
node tail = li->top->pre;
node pre = tail->pre;
#include "dataStruct.h"
#include <stdio.h>
#include <stdlib.h>
#include <malloc.h>
#include <string.h>
#define MAXSIZE 200
#define SAVEALL 0
#define APPEND 1
void add(list li, node newnd)
{
li->count++;
/*更改插入结点的前后关系*/
node temp = li->top->pre;
li->top->pre = newnd;
newnd->next = li->top;
newnd->pre = temp;
newnd->pre->next = newnd;
}
void order(list li)
{
/*采用插入排序,找到应插入的位置*/
node tail = li->top->pre;
node pre = tail->pre;
for (int n = 1; n < li->count; n++)
{
if (strcmp(tail->name, pre->name) < 0)
{
pre = pre->pre;
}
}
/*将待排序的尾结点从链表中移除,并将其插入pre所指结点之后*/
li->top->pre = tail->pre; //更改尾节点
tail->pre->next = li->top;
pre->next->pre = tail;
tail->next = pre->next; //插入
pre->next = tail;
tail->pre = pre;
}
void save(char *filename, list li, int type)
{
FILE *fp = NULL;
node buff = NULL;
if (type == APPEND)
{
if ((fp = fopen(filename, "ab")) != NULL)
{
buff = li->top->pre;
fprintf(fp, "%s %s %s/n", buff->name, buff->tell, buff->city);
}
else
{
if (strcmp(tail->name, pre->name) < 0)
{
pre = pre->pre;
}
}
/*将待排序的尾结点从链表中移除,并将其插入pre所指结点之后*/
li->top->pre = tail->pre; //更改尾节点
tail->pre->next = li->top;
pre->next->pre = tail;
tail->next = pre->next; //插入
pre->next = tail;
tail->pre = pre;
}
void save(char *filename, list li, int type)
{
FILE *fp = NULL;
node buff = NULL;
if (type == APPEND)
{
if ((fp = fopen(filename, "ab")) != NULL)
{
buff = li->top->pre;
fprintf(fp, "%s %s %s/n", buff->name, buff->tell, buff->city);
}
else
剩余8页未读,继续阅读
资源评论
- qq_240295572015-01-03好评,可以运行
- p111604292012-12-29代码很好 能运行
wguoyong
- 粉丝: 51
- 资源: 4
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功