数据结构课程设计活期储蓄账目管理系统含有排序和文章编译功能.docx

上传人:b****8 文档编号:30546441 上传时间:2023-08-16 格式:DOCX 页数:36 大小:21.97KB
下载 相关 举报
数据结构课程设计活期储蓄账目管理系统含有排序和文章编译功能.docx_第1页
第1页 / 共36页
数据结构课程设计活期储蓄账目管理系统含有排序和文章编译功能.docx_第2页
第2页 / 共36页
数据结构课程设计活期储蓄账目管理系统含有排序和文章编译功能.docx_第3页
第3页 / 共36页
数据结构课程设计活期储蓄账目管理系统含有排序和文章编译功能.docx_第4页
第4页 / 共36页
数据结构课程设计活期储蓄账目管理系统含有排序和文章编译功能.docx_第5页
第5页 / 共36页
点击查看更多>>
下载资源
资源描述

数据结构课程设计活期储蓄账目管理系统含有排序和文章编译功能.docx

《数据结构课程设计活期储蓄账目管理系统含有排序和文章编译功能.docx》由会员分享,可在线阅读,更多相关《数据结构课程设计活期储蓄账目管理系统含有排序和文章编译功能.docx(36页珍藏版)》请在冰豆网上搜索。

数据结构课程设计活期储蓄账目管理系统含有排序和文章编译功能.docx

数据结构课程设计活期储蓄账目管理系统含有排序和文章编译功能

题目:

活期储蓄帐目管理

活期储蓄处理中,储户开户、销户、存入、支出活动频繁,系统设计要求:

能比较迅速地找到储户的帐户,以实现存款、取款记账;并能实现排序

能比较简单,迅速地实现插入和删除,以实现开户和销户的需要。

一、主函数main

#include"文章编辑系统.h"

#include"排序子系统.h"

#include"活期帐目管理系统.h"

#include

#include

#include

usingnamespacestd;

voidmain()

{

intchoice;

charch;

ch='y';

while(ch=='y'||ch=='Y')

{

printf("\n\n\n\n\t\t数据结构实验演示系统\n\n\n");

printf("\t\t主菜单");

printf("\n\t\t**************************************");

printf("\n\t\t*1-------文章编辑系统*");

printf("\n\t\t*2-------排序子系统*");

printf("\n\t\t*3-------活期帐目管理系统*");

printf("\n\t\t*0-------退出*");

printf("\n\t\t**************************************");

printf("\n\n\t\t请选择菜单号(0--3):

");

scanf("%d",&choice);

getchar();

switch(choice)

{

case1:

Article();break;

case2:

sort();break;

case3:

Banksystem();break;

case0:

ch='n';break;

default:

printf("菜单选择错误!

请重新输入!

");

}

}

}

二、文章编译系统

#include

#include

#include

#include

usingnamespacestd;

structNode

{

charletter;

Node*next;

};

voidInitList(Node*L)

{//输入以"*"结束的文章

cout<<"\t\t\t输入一页文字(以*结束):

"<

while((L->letter=getchar())!

='*')

{

L->next=newNode;

L=L->next;

}

L->next=NULL;

cout<<"输入成功!

";

}

voidCountStr(Node*L)

{//统计某一字符串在文章中出现次数

intn=0;

chars[80],*q;

Node*p;

cout<<"\t\t\t输入一字符串:

";

cin>>s;

while(L->next)

{

for(p=L,q=s;*q!

='\0'&&p->next;p=p->next,q++)

if(p->letter!

=*q)break;

if(*q=='\0')n++;

L=L->next;

}

cout<<"\t\t\t字符串"<

}

Node*DelStr(Node*L)

{//删除某一子串

Node*H=L;

chars[80],*q;

Node*p;

cout<<"\t输入该子串:

";

cin>>s;

if(H->letter==*s)

{

for(p=H->next,q=s+1;*q!

='\0'&&p->next;p=p->next,q++)

if(p->letter!

=*q)break;

if(*q=='\0')H=p;

}

while(L->next)

{

for(p=L->next,q=s;*q!

='\0'&&p->next;p=p->next,q++)

if(p->letter!

=*q)break;

if(*q=='\0')L->next=p;

elseL=L->next;

}

returnH;

}

voidprint1(Node*L)

{//分行输出用户输入的各行字符

while(L->next)

{

cout<letter;

L=L->next;

}

cout<

}

voidprint2(Node*L,int&p1,int&p2,int&p3,int&n)

{//统计中英文字母和空格数以及整篇文章总字数

n=p1=p2=p3=0;

for(;L->next;L=L->next,n++)

if(isalpha(L->letter))p1++;

elseif(isdigit(L->letter))p2++;

elseif(L->letter=='')p3++;

elseif(L->letter=='\n')n--;

cout<<"\n\t\t\t全部字母数:

"<

cout<<"\n\t\t\t数字个数:

"<

cout<<"\n\t\t\t空格个数:

"<

cout<<"\n\t\t\t文章总字数:

"<

}

voidArticle()

{

system("cls");

Node*L=newNode;

intp1,p2,p3,n;

charchoice,ch;;

do

{

printf("\n\n\n\t\t\t========文章编辑系统==========\n");

printf("\t\t\t*1:

输入文章*\n");

printf("\t\t\t*2:

统计编辑*\n");

printf("\t\t\t*3:

显示文章*\n");

printf("\t\t\t*0:

返回*\n");

printf("\t\t\t********************************\n");

printf("\t\t请输入文章编辑系统菜单号:

");

cin>>choice;

switch(choice)

{

case'1':

InitList(L);break;

case'2':

{

printf("\t\t\t1:

统计中英文字母和空格数以及整篇文章总字数\n");

printf("\t\t\t2:

统计某一字符串在文章中出现次数\n");

printf("\t\t\t3:

删除某一子串\n");

printf("\t\t\t0:

返回\n");

do

{

printf("\t\t选择文章编辑操作:

");

cin>>ch;

switch(ch)

{

case'1':

print2(L,p1,p2,p3,n);break;

case'2':

CountStr(L);break;

case'3':

DelStr(L);break;

case'0':

ch='0';break;

default:

printf("\t\t输入错误!

请重新输入!

\n");break;

}

}while(ch!

='0');

break;

}

case'3':

print1(L);break;

case'0':

choice=0;break;

default:

printf("\t\t输入错误!

请重新输入!

\n");break;

}

}while(choice);

}

三、排序子系统

#include

#include

#include

#defineL8

#defineFALSE0

#defineTURE1

typedefstruct

{

intkey;

charotherinfo;

}RecType;

typedefRecTypeSeqlist[L+1];

intnum;

SeqlistR;

voidInsertsort();

voidBubblesort();

voidQuickSort(intlow,inthigh);

voidShellsort();

voidSelectsort();

voidMergesort();

intPartition(inti,intj);

voidHeap();

voidsort()

{

system("cls");

SeqlistS;

inti,k;

charch1,ch2,q;

printf("\n\t请输入%d个待排序数据(按回车分隔):

\n\t",L);

for(i=1;i<=L;i++)

{

scanf("%d",&S[i].key);

getchar();

printf("\t");

}

printf("\n\t排序数据已经输入完毕!

");

ch1='y';

while(ch1=='y'||ch1=='Y')

{

printf("\n");

printf("\n\t\t排序子系统");

printf("\n\t\t*************************************");

printf("\n\t\t*1----更新排序数据*");

printf("\n\t\t*2----直接插入排序*");

printf("\n\t\t*3----希尔排序*");

printf("\n\t\t*4----冒泡排序*");

printf("\n\t\t*5----快速排序*");

printf("\n\t\t*6----选择排序*");

printf("\n\t\t*7----归并排序*");

printf("\n\t\t*8----堆排序*");

printf("\n\t\t*0----返回*");

printf("\n\t\t*************************************");

printf("\n\t\t请选择菜单号(0--8):

");

scanf("%c",&ch2);

getchar();

for(i=1;i<=L;i++)

R[i].key=S[i].key;

switch(ch2)

{

case'1':

printf("\n\t\t请输入&d个待排序的数据(按回车分隔):

\n\t",L);

for(i=1;i<=L;i++)

{

scanf("%d",&S[i].key);

getchar();

printf("\t");

}

printf("\n\t排序数据已经输入完毕!

");

break;

case'2':

Insertsort();break;

case'3':

Shellsort();break;

case'4':

Bubblesort();break;

case'5':

printf("\n\t原始数据为(按回车开始排序):

");

for(k=1;k<=L;k++)

printf("%5d",R[k].key);

getchar();

printf("\n");

num=0;

QuickSort(1,L);

printf("\n\t排序的最终结果是:

");

for(k=1;k<=L;k++)

printf("%5d",R[k].key);

printf("\n");

break;

case'6':

Selectsort();break;

case'7':

Mergesort();break;

case'8':

Heap();break;

case'0':

ch1='n';break;

default:

printf("\n\t输入出错!

");

}

if(ch2!

='0')

{if(ch2=='2'||ch2=='3'||ch2=='4'||ch2=='5'||ch2=='6'||ch2=='7'||ch2=='8')

printf("\n\t排序输出完毕!

");

printf("\n\n\t按回车键返回.");

q=getchar();

if(q!

='\xA')

{

getchar();

ch1='n';

}

}

}

}

voidInsertsort()

{

inti,j,k,m=0;

printf("\n\t原始数据为(按回车开始排序):

");

for(k=1;k<=L;k++)

printf("%5d",R[k].key);

getchar();

printf("\n");

for(i=2;i<=L;i++)

{

if(R[i].key

{

R[0]=R[i];j=i-1;

while(R[0].key

{

R[j+1]=R[j];

j--;

}

R[j+1]=R[0];

}

m++;

printf("\t第%d趟排序结构为(按回车继续):

",m);

for(k=1;k<=L;k++)

printf("%5d",R[k].key);

getchar();

printf("\n");

}

printf("\n\t排序的最终结果是:

");

for(i=1;i<=L;i++)

printf("%5d",R[i].key);

printf("\n");

}

voidShellsort()

{

inti,j,gap,x,m=0,k;

printf("\n\t原始数据为(按回车开始排序):

");

for(k=1;k<=L;k++)

printf("%5d",R[k].key);

getchar();

printf("\n");

gap=L/2;

while(gap>0)

{

for(i=gap+1;i<=L;i++)

{

j=i-gap;

while(j>0)

{

if(R[j].key>R[j+gap].key)

{

x=R[j].key;R[j].key=R[j+gap].key;

R[j+gap].key=x;

j=j-gap;

}

else

j=0;

}

}

gap=gap/2;

m++;

printf("\t第%d趟排序结果为(按回车继续):

",m);

for(k=1;k<=L;k++)

printf("%5d",R[k].key);

getchar();

printf("\n");

}

printf("\n\t排序的最终结果是:

");

for(k=1;k<=L;k++)

printf("%5d",R[k].key);

printf("\n");

}

voidBubblesort()

{

inti,j,k;

intexchange;

printf("\n\t原始数据为(按回车开始排序:

");

for(k=1;k<=L;k++)

printf("%5d",R[k].key);

getchar();

printf("\n");

for(i=1;i

{

exchange=FALSE;

for(j=L;j>=i+1;j--)

if(R[j].key

{

R[0].key=R[j].key;

R[j].key=R[j-1].key;

R[j-1].key=R[0].key;

exchange=TURE;

}

if(exchange)

{

printf("\t第%d趟排序结果为(按回车继续:

",i);

for(k=1;k<=L;k++)

printf("%5d",R[k].key);

getchar();

printf("\n");

}

}

printf("\n\t排序的最终结果是:

");

for(i=1;i<=L;i++)

printf("%5d",R[i].key);

printf("\n");

}

intPartition(inti,intj)

{

RecTypepirot=R[i];

while(i

{

while(i=pirot.key)

j--;

if(i

R[i++]=R[j];

while(i

i++;

if(i

R[j--]=R[i];

}

R[i]=pirot;

returni;

}

voidQuickSort(intlow,inthigh)

{

intpirotpos,k;

if(low

{

pirotpos=Partition(low,high);

num++;

printf("\t第%d趟排序结果为(按回车继续):

",num);

for(k=1;k<=L;k++)

printf("%5d",R[k].key);

getchar();

printf("\n");

QuickSort(low,pirotpos-1);

QuickSort(pirotpos+1,high);

}

}

voidSelectsort()

{

inti,j,k,h;

printf("\n\t原始数据为(按回车继续:

");

for(k=1;k<=L;k++)

printf("%5d",R[k].key);

getchar();

printf("\n");

for(i=1;i

{

h=i;

for(j=i+1;j<=L;j++)

if(R[j].key

h=j;

if(h!

=j)

{

R[0]=R[i];

R[i]=R[h];

R[h]=R[0];

}

printf("\t第%d趟排序结果为(安回车继续):

",i);

for(k=1;k<=L;k++)

printf("%5d",R[k].key);

getchar();

printf("\n");

}

printf("\n\t排序的最终结果是:

");

for(i=1;i<=L;i++)

printf("%5d",R[i].key);

printf("\n");

}

voidMerge(intlow,intmm,inthigh)

{

inti=low,j=mm+1,p=0;

RecType*R1;

R1=newRecType[high-low+1];

if(!

R1)

printf("\n\t内存容量不够!

");

while(i<=mm&&j<=high)

R1[p++]=(R[i].key<=R[j].key)?

R[i++]:

R[j++];

while(i<=mm)

R1[p++]=R[i++];

while(j<=high)

R1[p++]=R[j++];

for(p=0,i=low;i<=high;p++,i++)

R[i]=R1[p];

}

voidMergePass(intlength)

{

inti;

for(i=1;i+2*length-1<=L;i=i+2*length)

Merge(i,i+length-1,i+2*length-1);

if(i+length-1

Merge(i,i+length-1,L);

}

voidMergesort()

{

intlength,k,m=0;

printf("\n\t原始数据为(按回车键开始排序):

");

for(k=1;k<=L;k++)

printf("%5d",R[k].key);

getchar();

printf("\n");

for(length=1;length

{

MergePass(length);

m++;

printf("\t第%d趟排序结果为(按回车继续):

",m);

for(k=1;k<=L;k++)

printf("%5d",R[k].key);

getchar();

printf("\n");

}

printf("\n\t排序的最终结果是:

");

for(k=1;k<=L;k++)

printf("%5d",R[k].key);

printf("\n");

}

voidCreateHeap(introot,intindex)//堆栈

{

intj,temp,finish;

j=2*root;

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

当前位置:首页 > 幼儿教育 > 少儿英语

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

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