C语言编程-数据结构课程设计-文本编辑器,已经提供代码,若干问题
题目: 文本编辑器
功能:实现基本的文本输入功能:查找,替换,插入,删除,正确显示行数,可正确存盘,读盘。
要求:1)界面友好,函数功能要划分好
2)总体设计应画一流程图
3)程序要加必要的注释
4)要提供程序测试方案
5)程序一定要经得起测试,宁可功能少一些,也要能运行起来,不能运行的程序是没有价值的。
代码:(可以运行,无错误,无警告)
#include "stdio.h"
#include "stdlib.h"
#define OK 1
#define ERROR 0
#define OVERFLOW -1
//#define EOF -1
#define STACK_INIT_SIZE 10
#define STACKINCREMENT 1000
#define MAXQSIZE 10
static int i=0;
typedef char ElemType;
typedef struct StackNode//构造栈
{
ElemType *base;
ElemType *top;
int stacksize;
}SqStack;
ElemType InitStack(SqStack *S)//初始化栈
{
S->base=(ElemType *)malloc(STACK_INIT_SIZE*sizeof(ElemType));
if(!S->base)
{
exit(OVERFLOW);
}
S->top=S->base;
S->stacksize=STACK_INIT_SIZE;
return OK;
}
ElemType StackEmpty(SqStack *S)//判断栈是否为空
{
if(S->top==S->base)
return OK;
else
return ERROR;
}
ElemType Push(SqStack *S,ElemType e)//进栈操作
{
if(S->top-S->base>=S->stacksize)
{
S->base = (ElemType *)realloc(S->base,(S->stacksize+STACKINCREMENT)*sizeof(ElemType));
if(!S->base)
{
exit(OVERFLOW);
}
S->top = S->base+S->stacksize;
S->stacksize+=STACKINCREMENT;
}
*S->top++=e;
return OK;
}
ElemType Pop(SqStack *S,ElemType *e)//出栈操作
{
if(S->top==S->base)
{
return ERROR;
}
*e=*--S->top;
//printf("%d\n",e);
// return e;
return 0;
}
void ClearStack(SqStack *S)//清空栈
{
S->top=S->base;
}
ElemType LineEdit(SqStack *S )//文本编译
{
char ch, e, a[30];
int i ;
ch = getchar();
while(1)
{
while (ch!='\n')
{
switch(ch)
{
case '#':
Pop(S,&e);
break;
case '@':
ClearStack(S);
break;
default:
Push(S,ch);
break;
}
ch = getchar();
}
i = 0;
while (!StackEmpty(S))
{
Pop(S,&e);
a[i++]=e;
}
for(--i; i>= 0; i--)
{
printf("%c",a[i]);
}
printf("\n");
ClearStack(S);
ch = getchar();
}
return 0;
}
int main(void)
{
SqStack S;
InitStack(&S);
LineEdit(&S);
system("pause");
return 0;
}
我用visual c++6.0 编译后,弹出来运行窗口,可是我不知道该输入什么数据。。。
哪位编成高手能帮我解答一下,或加我好友,要多少分都行啊,这个号1000多分呢,只要能指导我一下就行。
题目要求的界面友好,可是怎么这个代码没有界面,怎么才有界面?
我那课程没学好....一楼的我看不懂,好像弄得更复杂了...
周五要交,怎么办?