资源简介
链串实现的文本编辑器,封装了各种操作的方法,如求长度,插入字符等等。
代码片段和文件信息
#include “stdio.h“
struct linkNode{
char value;
struct linkNode* next;
};
struct linkNode* createlink();
int addstr(struct linkNode* headNode char c);
void printstr(struct linkNode* headNode);
main(){
char input;
struct linkNode* headNode;
headNode=createlink();
do{
input=getch();
if((input>=‘0‘&&input<=‘9‘)||(input>=‘A‘&&input<=‘Z‘)||(input>=‘a‘&&input<=‘z‘)||input==‘ ‘){
printf(“%c“input);
addstr(headNodeinput);
}
if(input==‘\b‘){
printf(“\b \b“);
}
if(input==‘\r‘){
printf(“\r\n“);
addstr(headNodeinput);
}
}while(input!=27) ;
deletestr(headNode“aaa“);
/* replacestr(headNode“aaa““cccc“);*/
printf(“\n“);
printstr(headNode);
printf(“\nspace in the passage:%d“ countspace(headNode));
printf(“\nchar in the passage:%d“ countchar(headNode));
printf(“\nword in the passage:%d“ countword(headNode));
printf(“\nnumber in the passage:%d“ countnum(headNode));
getch();
}
struct linkNode* createlink(){
struct linkNode* h;
h=(struct linkNode*)malloc(sizeof(struct linkNode));
h->next=NULL ;
h->value=NULL;
return h;
}
int addstr(struct linkNode* headNodechar c){
struct linkNode* unit;
struct linkNode* p;
unit=(struct linkNode*)malloc(sizeof(struct linkNode));
unit->next=NULL;
unit->value=c;
p=headNode;
while(p->next!=NULL)p=p->next; /*move to end;*/
p->next=unit;
}
void printstr(struct linkNode* headNode){
struct linkNode* p;
char input;
p=headNode;
while(p->next!=NULL){
p=p->next;
input=p->value;
if((input>=‘0‘&&input<=‘9‘)||(input>=‘A‘&&input<=‘Z‘)||(input>=‘a‘&&input<=‘z‘)||input==‘ ‘){
printf(“%c“input); }
if(input==‘\r‘){
printf(“\r\n“);
}
}
}
int countspace(struct linkNode* headNode){
struct linkNode* p;
char input;
int count=0;
p=headNode;
while(p->next!=NULL){
p=p->next;
input=p->value;
if(input==‘ ‘){
count++;
}
}
return count;
}
int countchar(struct linkNode* headNode){
struct linkNode* p;
char input;
int count=0;
p=headNode;
while(p->next!=NULL){
p=p->
- 上一篇:libncurses.so.5.5
- 下一篇:数据要求说明书---说明
相关资源
- 数据结构年终考题范围和答案 耿国华
- 数据结构 朱战力 习题解答 数据结构
- 数据结构课程设计 6 1 彩票系统
- 教学计划编制系统
- 大数(链表、数组)实现
- 自己写的航空订票系统c 版--数据结构
- 数据结构实验魔王语言
- 航空订票系统_数据结构课程设计
- 多项式求和(数据结构C 版)
- 尚观培训linux董亮老师关于数据结构的
- 数据结构 知识点总结
- 华南理工大学数据结构复习提纲二
- 华南理工大学数据结构复习提纲一
- 数据结构用C 写的停车场系统源代码
- 数据结构(河北科技大学)
- 数据结构考前习题 清华大学出版社
- 数据结构课件(北邮)
- 数据结构实验 基于栈的表达式求值
- 数据结构课程设计——图书管理系统
- 成绩管理系统(数据结构)
- 数据结构-最小通信网问题
- 数据结构课程设计同学通讯录系统
- 数据结构课程设计 公园导游图
- 数据结构殷人昆版的课后答案
- 2006年湖北工业大学409数据结构试题
- 数据结构实验-魔王语言-源码加实验报
- 简单计算器的实现(数据结构)
- 简单计算器的实现(数据结构 修正版
- Fundamentals of Data Structure in C
- 北京邮电大学数据结构历年考研真题
评论
共有 条评论