学了一学期的数据结构 ,个人感觉该课程重在思想,只要思路正确,就肯定可以编出好程序来。选了简单行编辑的课程设计 ,里面主要用到的数据结构有指针链表。C语言 方面用到了很多文件读写操作。
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <conio.h>
#include <windows.h>
#define OK 0
typedef struct linedit
{
char string[80];
struct linedit *next;
struct linedit *pre;
int len;
int dflag;
}linedit;
FILE *fp,*pf;
linedit *head;
int n=0,sum,delsizen,change=0,page=0,pflag=0;
int x0,y0;
void gotoxy(int x,int y);
void Createlist();
void freemem();
int initFile();
int display();
int saveanddisplay(int col);
int saveall();
int delet();
int insert();
void gotoxy(int x,int y)
{
COORD coord;
coord.X=x;
coord.Y=y;
SetConsoleCursorPosition( GetStdHandle( STD_OUTPUT_HANDLE ), coord );
}
void Createlist()
{
linedit *p1,*p2;
system("cls");
if(!fp||!pf)
{
printf("建立链表失败,你应该先进行打开文件操作(初始化文件)!");
printf("按任意键返回...");
getch();
return;
}
p1=p2=(linedit *)malloc(sizeof(linedit));
head=NULL;
while(n<10)
{
n=n+1; &n