《数据结构》课程设计报告简单编辑器构造n个城市连接的最小生成树Word文档下载推荐.docx

上传人:b****6 文档编号:17545915 上传时间:2022-12-07 格式:DOCX 页数:33 大小:422.04KB
下载 相关 举报
《数据结构》课程设计报告简单编辑器构造n个城市连接的最小生成树Word文档下载推荐.docx_第1页
第1页 / 共33页
《数据结构》课程设计报告简单编辑器构造n个城市连接的最小生成树Word文档下载推荐.docx_第2页
第2页 / 共33页
《数据结构》课程设计报告简单编辑器构造n个城市连接的最小生成树Word文档下载推荐.docx_第3页
第3页 / 共33页
《数据结构》课程设计报告简单编辑器构造n个城市连接的最小生成树Word文档下载推荐.docx_第4页
第4页 / 共33页
《数据结构》课程设计报告简单编辑器构造n个城市连接的最小生成树Word文档下载推荐.docx_第5页
第5页 / 共33页
点击查看更多>>
下载资源
资源描述

《数据结构》课程设计报告简单编辑器构造n个城市连接的最小生成树Word文档下载推荐.docx

《《数据结构》课程设计报告简单编辑器构造n个城市连接的最小生成树Word文档下载推荐.docx》由会员分享,可在线阅读,更多相关《《数据结构》课程设计报告简单编辑器构造n个城市连接的最小生成树Word文档下载推荐.docx(33页珍藏版)》请在冰豆网上搜索。

《数据结构》课程设计报告简单编辑器构造n个城市连接的最小生成树Word文档下载推荐.docx

4、系统功能模块介绍

整体框架图:

主要函数说明

1.CreatWord()文本输入函数。

2.PrintWord()当前文本内容输出函数,将当前存储在链表中的文本内容输出;

3.CountWord()文章内容统计函数,对存储在链表中文本内容进行统计,包括对文本内容中的大写字母、小写字母、数字、标点符号、空格以及文章所有字数的个数的统计;

4.SearchWord()文章内容查找函数;

5.DeleteWord()文章内容删除函数;

6.InsertWord()文章内容插入函数;

7.Dealmenu()子菜单函数

8.help()帮主函数

9.About()显示作者信息的函数

10.menu()主菜单函数,

11.main()主函数

5、程序清单

#include"

stdio.h"

malloc.h"

string.h"

iostream.h"

stdlib.h"

conio.h"

windows.h"

#defineLink_Size100

intNUM,C,N;

typedefstructlist

{

chardata[80];

intlength;

structlist*next;

structlist*pre;

introw;

}LinkList;

LinkList*head;

LinkList*CreatWord()

LinkList*temp;

charch;

inti,j;

head->

next=(LinkList*)malloc(sizeof(LinkList));

pre=NULL;

temp=head->

next;

temp->

length=0;

for(i=0;

i<

80;

i++)

data[i]='

\0'

;

printf("

开始创建文本,请输入文章(输入#号结束):

\n"

);

for(j=0;

j<

Link_Size;

j++)

{

ch=getchar();

data[i]=ch;

length++;

if(ch=='

#'

NUM=j;

break;

}

length=i;

next=NULL;

next=(LinkList*)malloc(sizeof(LinkList));

next->

pre=temp;

temp=temp->

}

temp->

row=NUM+1;

system("

cls"

returntemp;

voidgotoxy(intx,inty)

COORDc;

c.X=x-1;

c.Y=y-1;

SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),c);

intMenu_select(intx1,intx2,intn)

intp=0,keyhit;

while

(1)

{

keyhit=getch();

gotoxy(x1,7+p);

printf("

"

gotoxy(x2+8,7+p);

switch(keyhit)

{

case72:

//按上方向键

if(p>

0)

p--;

else

p=n-1;

break;

case80:

//按下方向键

if(p<

n-1)

p++;

p=0;

case13:

//按回车键

returnp;

default:

}

>

"

<

voidPrintWord()

LinkList*p;

p=head->

system("

printf("

\n\n\n\n\t\t******简单文本编辑器******\n\n"

if(p==NULL){printf("

/n/n/t请先输入文本!

exit(0);

\n当前文章的内容是:

for(j=0;

=NUM&

&

p!

=NULL;

for(i=0;

(i<

80)&

(p->

data[i])!

='

printf("

%c"

p->

data[i]);

p=p->

voidCountWord()

intWORD=0,word=0,space=0,num=0,punct=0,sum=0;

=NUM;

(temp->

ch=temp->

data[i];

if((ch>

A'

)&

(ch<

Z'

))

WORD++;

elseif((ch>

a'

z'

word++;

0'

9'

num++;

elseif(ch=='

'

space++;

elseif(ch==33||ch==34||ch==39||ch==44||ch==46||ch==58||ch==59||ch==63)

{punct++;

sum=WORD+word+num;

}

\t\t****************************************************\n"

\t\t****文章内容统计菜单****\n"

\t\t\t文章中大写字母的个数:

%d\n"

WORD);

\t\t\t文章中小写字母的个数:

%d\n"

word);

\t\t\t文章中数字的个数:

num);

\t\t\t文章中标点符号的个数:

punct);

\t\t\t文章中空格的个数:

space);

\t\t\t文章中所有字数:

sum);

\n\n\t按任意键退出返回主菜单\n"

getchar();

voidSearchWord(char*str1,LinkList*temp)

{

charData[20];

inti,j,k=0,sum=0;

intl=1;

strcpy(Data,str1);

i++)

j++)

if((temp->

data[j])==Data[k])k++;

elseif(Data[k]!

{

j=j-k;

k=0;

}

if(Data[k]=='

sum++;

j=j-k+1;

\t\t第%d次出现在第%d行第%d列\n"

l,i+1,j+1);

l++;

k=0;

continue;

}

\t\t\t字符串总共出现次数为:

%d\n\n"

C=sum;

N=i*80+j;

voidDeleteWord(char*str2)

{charData[20];

LinkList*temp,*term;

inti,j,k,m,y,num;

strcpy(Data,str2);

for(y=0;

y<

C;

y++)

num=80;

k=0,m=0;

temp=head;

{

term=temp;

temp=temp->

for(j=0;

{

if((temp->

elseif(Data[k]!

){j=j-k;

k=0;

if(Data[k]=='

{

num=j;

break;

}

if(num<

80)break;

}

for(;

for(;

if(j+1<

k)

{

term->

data[80-k+num]=temp->

data[j+1];

else

temp->

data[j-k+1]=temp->

j=0;

LinkList*InsertWord(LinkList*temp)

charData[20];

inth,l;

\n\t\t请输入要插入的字符或字符串:

gets(Data);

\n\t\t当前文章内容为:

PrintWord();

\n\t\t请输入要插入的行:

scanf("

%d"

&

h);

\n\t\t请输入要插入的列:

l);

inti=(h-1)*80+l;

LinkList*a;

intn=strlen(Data);

intm;

intinsertRow=i/80+1;

introw=temp->

row;

intj;

if(insertRow==row)

for(m=temp->

length-1;

m>

=(i%80)&

n>

0;

m--)

temp->

data[m+n]=temp->

data[m];

for(m=(i%80),j=0;

m<

n+(i%80);

m++,j++)

data[m]=Data[j];

else

intr=0;

for(intp=insertRow;

p<

p++)

if(p==insertRow)

r=0;

else

r=n;

for(m=temp->

length-1-r;

=0&

a=temp;

temp=temp->

pre;

length=80;

for(m=temp->

length-n,j=0;

length;

a->

data[j]=temp->

length-n-1;

=(i%80);

m--)

(i%80)+n;

m++,j++)

data[m]=Data[j];

returntemp;

voidDealmenu(LinkList*temp)

charstr1[20];

charstr2[20];

intcursor;

do

{printf("

\n\n\n\n\t\t******简单文本编辑器******\n"

\t\t****文章内容处理菜单****\n"

\t\t\t>

查找<

\t\t\t删除\n"

\t\t\t插入\n"

\t\t\t显示当前文章内容\n"

\t\t\t返回主菜单\n"

\t\t\t退出\n\n"

cursor=Menu_select(25,41,6);

switch(cursor)

case0:

\t\t\t请输入您需要查找的字符或字符串:

gets(str1);

SearchWord(str1,temp);

按回车键继续·

·

getchar();

system("

break;

case1:

\t\t\t请输入您需要删除的字符或字符串:

gets(str2);

SearchWord(str2,temp);

DeleteWord(str2);

\t\t\t删除%s后的文章为:

str2);

case2:

InsertWord(temp);

\t\t\t插入字符或字符串后文章为:

case3:

if(cursor==4)

if(cursor==5)exit(0);

}while

(1);

voidAbout()

\n\n\t\t************关于**********\n"

\t\t**制作时间:

2010年6月**\n"

voidmenu(LinkList*temp)

intcursor;

temp=CreatWord();

{system("

显示当前文本内容<

\t\t\t内容统计\n"

\t\t\t文本处理菜单\n"

\t\t\t帮助\n"

\t\t\t关于\n"

cursor=Menu_select(25,41,6);

if(cursor==0)

{system("

if(cursor==1)

CountWord();

if(cursor==2)

Dealmenu(temp);

if(cursor==3)

if(cursor==4)

About();

if(cursor==5){printf("

\n谢谢使用...\n"

}while(5);

voidmain()

\n\n\n\n"

\t\t****欢迎使用简单文本编辑器****\n"

\t\t********\n"

\t\t****按任意键继续...****\n"

head=(LinkList*)malloc(sizeof(LinkList));

LinkList*temp;

menu(temp);

6、运行及调试分析

文本输入界面:

输入文本:

主菜单:

文本内容处理菜单:

文本统计界面:

题目2:

构造n个城市连接的最小生成树

一个地区的n个城市间的距离网,用Prim算法或Kruskal算法建立最小生成树,并计算得到的最小生成树的代价。

基本要求:

1)城市间的距离网采用邻接矩阵表示,邻接矩阵的存储结构定义采用课本中给出的定义,若两个城市之间不存在道路,则将相应边的权值设为自己定义的无穷大值。

要求在屏幕上显示得到的最小生成树中包括

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > IT计算机 > 计算机软件及应用

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1