当前位置:文档之家› 数据结构课程设计:文章编辑系统 源代码

数据结构课程设计:文章编辑系统 源代码

#include"stdio.h"
#include"string.h"
#include"math.h"
#include"malloc.h"
#include
#include
#include"time.h"
#include
#include
#include
#include"stdlib.h"
#pragma comment(lib,"WinMM.Lib")



typedef struct Line{
char data[100];//每行内容用这样一个结点存放
struct Line *next;
}Line,*Article;


int m=0;//该全局变量用来改变系统所使用的语言..登录时默认语言为中文
int times;//此全局变量为删除和替换字符串时使用
int ii;//跟times同一功能
int tt=0;
int colori=1;
int music=0;

//设置系统颜色
void color()
{
int col;
col=colori;
if(m!=1)
{
printf("\t\t ¤1.黑底白字");
printf("\t\t●2.蓝底红字\n");
printf("\t\t ¤3.白底黑字");
printf("\t\t●4.绿底红字\n");
printf("\t\t ¤5.红底绿字");
printf("\t\t●6.白底紫字\n");
printf("\t\t ¤7.紫底白字");
printf("\t\t●8.黑底黄字\n");
printf("\t\t ¤9.黑底蓝字");
printf("\t\t●10.黑底灰字\n");
printf("\t\t ¤11.白底红字");
printf("\t●0.返回\n\n");
printf("\t 请输入你要更换的颜色并回车:");
scanf("%d",&colori);
if(colori==0)
colori=col;
switch(colori)
{
case 1:system("color 07");break;
case 2:system("color 9c");break;
case 3:system("color f0");break;
case 4:system("color 2c");break;
case 5:system("color c2");break;
case 6:system("color fd");break;
case 7:system("color df");break;
case 8:system("color 0e");break;
case 9:system("color 09");break;
case 10:system("color 08");break;
case 11:system("color fc");break;
case 0:break;
default:printf("\t\t输入错误!");system("pause");break;
}
}
else
{
printf("\t ¤1.Black and White");
printf("\t\t●2.Blue and Red\n");
printf("\t ¤3.White and Black");
printf("\t\t●4.Green and Red\n");
printf("\t ¤5.Red and Green");
printf("\t\t●6.White and purple\n");
printf("\t ¤7.Purple and White");
printf("\t●8.Black and Yellow\n");
printf("\t ¤9.Black and Blue");
printf("\t\t●10.Black and Gray\n");
printf("\t ¤11.White and Red");
printf("\t\t●0.Exit\n\n");
printf("\t Please select the number of color and then preass enter:");
scanf("%d",&colori);
if(colori==0)
colori=col;
switch(colori)
{
case 1:system("color 07");break;
case 2:system("color 9c");break;
case 3:system("color f0");break;
case 4:system("color 2c");break;
case 5:system("color c2");break;
case 6:system("color fd");break;
case 7:system("color df");break;
case 8:system("color 0e");break;
case 9:system("color 09");break;
case 10:system("color 08");break;
case 11:system("color fc");break;
case 0:break;
default:printf("\t\tERROR!");system("pause");break;
}
}
}


void restorecolor()
{
switch(colori)
{
case 1:system("color 07");break;
case 2:system("color 9c"

);break;
case 3:system("color f0");break;
case 4:system("color 2c");break;
case 5:system("color c2");break;
case 6:system("color fd");break;
case 7:system("color df");break;
case 8:system("color 0e");break;
case 9:system("color 09");break;
case 10:system("color 08");break;
case 11:system("color fc");break;
}
}

//从文件中读取
void ReadFile(Article &head)
{
Line *p,*tail=head;
char s[100];
FILE *fp;
if((fp=fopen("D:\\article.txt","r"))==NULL)//先判断文章是否存在
{
if(m!=1)
printf("\n\t\t无法读取article.txt文件中的文章!\n");
else
printf("\n\t\tthe file of article.txt can't be read!\n");
return;
}
while((fgets(s,100,fp))!=NULL)
{
s[strlen(s)-1]='\0';
p=(Line*)malloc(sizeof(Line));
p->next=NULL;
strcpy(p->data,s);
if(head==NULL)
head=p;
else
tail->next=p;
tail=p;
}
if(m!=1)
printf("\n\t\t已成功从D盘的article.txt目录中读取文章!\n");
else
printf("\n\t\tThe article in D:\article.txt has succeed to read!\n");
fclose(fp);
}



//更改后保存到文件中
void SaveArticle(Article head)
{
FILE*fp;
char s[100];
int n;
Line *p=head;
if((fp=fopen("D:\\article.txt","w"))==NULL)
{
if(m!=1)
printf("\n\t\t无法打开article.txt文件中的文章!\n");
else
printf("\n\t\tCan not open file article.txt!\n");
return;
}
while(p != NULL) //将文章写入文件中
{
strcpy(s,p->data);
n=strlen(s);
s[n]='\n';
s[n+1]='\0';
fputs(s,fp);
p=p->next;
}
fclose(fp);
}



//是否要保存到文本中??...新建文章
void CreateFile(Article head)
{
FILE*fp;
char s[100];
int n;
Line *p=head;
if((fp=fopen("D:\\article.txt","w"))==NULL)
{
if(m!=1)
printf("\n\t\t无法打开article.txt文件中的文章!\n");
else
printf("\n\t\tCan not open file article.txt!\n");
return;
}
while(p!=NULL) //将文章写入文件中
{
strcpy(s,p->data);
n=strlen(s);
s[n]='\n';
s[n+1]='\0';
fputs(s,fp);
p=p->next;
}
if(m!=1)
printf("\n\t\t文章已成功写入D盘的article.txt目录中!\n");
else
printf("\n\t\tThe article has been successfully written in the D:article.txt!\n");
fclose(fp);
}


//是否现在输入内容在指定盘里存放该文章
void CreateArticle(Article &head)
{
Line *p,*tail;
char ch[100];
if(m!=1)
printf("\n\t\t请输入文章内容(按ctrl+e结束):\n");
else
printf("\n\t\tPlease input the content,end with (ctrl+e):\n");
while(1)
{
gets(ch);
p=(Line*)malloc(sizeof(Line));
p->next=NULL;
strcpy(p->data,ch);
if(p->data[strlen(p->data)-1]==5)
{
p->data[strlen(p->data)-1]='\0';
break;
}
if(head==NULL)
{
head=p;
tail=p;
}
else
{
tail->next=p;
tail=tail->next;
}
}
if(strlen(p->data)>0)
{
if(head==NULL)
{
head=p;
tail=p;
}
else
{
tail->next=p;
tail=tail->next;
}
}

}

//是否保存文章到指定目录的文件
void IsSave(Article head)
{
char ch;
if(m!=1)
printf("\t\t是否要将文章保存到指定目录的文件中?\n\t\t若是,请输入Y,若否,按其它任意键:");
else
printf("\t\tDo you want to save the file to the directory?\n\t\tIf yes,please input Y,or input any keys:");
ch=getchar();
if(ch=='Y'||ch=='y')
CreateFile(head);
}





//计算中文个数
int CountChinese(Article head)
{
int num=0;
Line *p=head;
int i;
int n;
while(p!=NULL)
{
n=strlen(p->data);
for(i=0;i{
if(p->data[i]<0)
num++;
}
p=p->next;
}
return num/2;
}


//计算字母个数
int CountLetter(Article head)
{
int num=0;
Line *p=head;
int i;
int n;
while(p!=NULL)
{
n=strlen(p->data);
for(i=0;i{
if(('a'<=p->data[i]&&'z'>=p->data[i])||('A'<=p->data[i]&&'Z'>=p->data[i]))
num++;
}
p=p->next;
}
return num;
}



//计算空格个数
int CountSpace(Article head)
{
int num=0;
Line *p=head;
int i;
int n;
while(p!=NULL)
{
n=strlen(p->data);
for(i=0;i{
if(p->data[i]==' ')
num++;
}
p=p->next;
}
return num;
}


//计算数字个数
int CountFigure(Article head)
{
int num=0;
Line *p=head;
int i;
int n;
while(p!=NULL)
{
n=strlen(p->data);
for(i=0;i{
if('0'<=p->data[i]&&p->data[i]<='9')
num++;
}
p=p->next;
}
return num;
}



//计算总字数
int CountArticle(Article head)
{
int num=0;
num=CountLetter(head)+CountSpace(head)+CountFigure(head)+CountChinese(head);
return num;
}





//找串...统计某一字符串在文章中出现的次数,并输出该次数
int FindString(Article head,char *s)
{
int num=0;
Line *p=head;
int i,j,k=1,t;
int n,mm;
while(p!=NULL)
{
n=strlen(p->data);
mm=strlen(s);
for(i=0;i<=(n-mm);)
{
k=1;
for(j=i,t=0;tif(p->data[j]!=s[t])
{
k=0;
break;
}
if(k)
{
num++;
i=i+strlen(s);
}
else
i++;
}
p=p->next;
}
return num;
}



//删除模块(删除全部要删除的串)
char* delstring1(char *ch,char *s)
{
int n=strlen(ch),mm=strlen(s);
int i,j,k,t;
for(i=0;i<=n-mm;)
{
k=1;
for(j=i,t=0;tif(ch[j]!=s[t])
{
k=0;
break;
}
if(k)
{
for(j=i;jch[j]=ch[j+mm];
ch[j]='\0';
}
else
i++;
n=strlen(ch);
}
return ch;
}


//全部删除
void DeleteString1(Article &head,char *s)
{
Line *p=head;
while(p!=NULL)
{
strcpy(p->data,delstring1(p->data,s));
p=p->next;
}
if(m!=1)
printf("\t\t全部已成功删除!\n");
else
printf("\t\tDelete all successfully!\n");
}


void delprint(char *ch,char *s)
{
int i;
int mm=strlen(s);
char c[100];
int k;
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_RED | FOREGROUND_G

REEN);
for(i=ii,k=0;ic[k]=ch[i];
c[k]='\0';
printf("%s",c);
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
}



//判断该行是否出现该字符串,出现返回1
int deljudge(char *ch,char *s)
{
int n=strlen(ch),mm=strlen(s);
int i,j,k,t;
for(i=ii;i<=n-mm;i++)
{
k=1;
for(j=i,t=0;tif(ch[j]!=s[t])
{
k=0;
break;
}
if(k)
{
times++;
ii=i;
return 1;
}
}
return 0;
}



char* delstring2(char *ch,char *s)
{
int n=strlen(ch),mm=strlen(s);
int i,j,k,t;
for(i=ii;i<=n-mm;i++)
{
k=1;
for(j=i,t=0;tif(ch[j]!=s[t])
{
k=0;
break;
}
if(k)
{
for(j=i;jch[j]=ch[j+mm];
ch[j]='\0';
ii=i;
break;
}
}
if(m!=1)
printf("\t\t删除成功!\n");
else
printf("\t\tDelete successfully!\n");
return ch;
}


//删除模块(删除一个指定位置要删除的串)
void DeleteString2(Article &head,char *s)
{
Line *p=head;
int flag;
char c;
int mm=strlen(s);
int i;
ii=0;
times=0;
while(p!=NULL) //这里出现的问题应该还是读入问题1!!
{
flag=deljudge(p->data,s);
if(flag)
{
if(m!=1)
printf("\t\t第%d次出现该字符串的所在行如下:\n",times);
else
printf("\t\tThe line that this string appears the %d time is:\n",times);
for(i=0;iprintf("%c",p->data[i]);
delprint(p->data,s);
for(i=ii+mm;idata);i++)
printf("%c",p->data[i]);
printf("\n");
if(m!=1)
printf("\t\t是否要删除?\n\t\tY是,N否:");
else
printf("\t\tDelete or not?\n\t\tY to yes,N to no:");
c=getchar(); getchar();
if(c=='Y'||c=='y')
strcpy(p->data,delstring2(p->data,s));
else
ii+=mm;
printf("\n");
if(m!=1)
printf("\t\t是否要继续删除?\n\t\tY是,N否:");
else
printf("continue to delete?\n\t\tY to yes ,N to no:");
c=getchar();getchar();
if(c=='N'||c=='n')
break;
}
else
{
p=p->next;
ii=0;
}
}
if(m!=1)
printf("\t\t删除结束!\n");
else
printf("\t\tDeleting ends!\n");
}


//删除管理模块
void deletemanage(Article &head,char *s)
{
int choice;
if(m!=1)
printf("\t\t1.全部删除\n\t\t2.部分删除\n\n\t\t请选择:");
else
printf("1.Delete all\n 2.Delete sections\n\n\t\tPlease select:");
scanf("%d",&choice);
getchar();
if(choice==1)
DeleteString1(head,s);
else
DeleteString2(head,s);
}






//字符串替换
//全部替换
char* repstring1(char *ch,char *s1,char *s2)
{
int n,mm,x,y;
int i,j,k,t;
n=strlen(ch);
mm=strlen(s1);
for(i=0;i<=n-mm;)
{
k=1;
for(j=i,t=0;tif(ch[j]!=s1[t])
{
k=0;
break;
}
if(k)
{
x=strlen(s2);
if(x<=mm)
{
for(j=i,t=0;tch[j]=s2[t

];
for(t=mm+i;jch[j]=ch[t];
ch[j]='\0';
}
else
{
y=x-mm;
for(t=n-1;t>=mm+i;t--)
ch[t+y]=ch[t];
ch[n+y]='\0';
for(j=i,t=0;tch[j]=s2[t];
}
i=i+x;
}
else
i++;
}
return ch;
}


void ReplaceString1(Article &head,char *s1,char *s2)//s2替换s1
{
Line *p=head;
while(p!=NULL)
{
strcpy(p->data,repstring1(p->data,s1,s2));
p=p->next;
}
if(m!=1)
printf("\t\t全部已成功替换!\n");
else
printf("\t\tReplace all successfully!\n");
}





//部分替换
void repprint(char *ch,char *s)
{
int i;
int mm=strlen(s);
char c[100];
int k;
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_RED | FOREGROUND_GREEN);
for(i=ii,k=0;ic[k]=ch[i];
c[k]='\0';
printf("%s",c);
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
}


int repjudge(char *ch,char *s)
{
int n=strlen(ch),mm=strlen(s);
int i,j,k,t;
for(i=ii;i<=n-mm;i++)
{
k=1;
for(j=i,t=0;tif(ch[j]!=s[t])
{
k=0;
break;
}
if(k)
{
times++;
ii=i;
return 1;
}
}
return 0;
}


char* repstring2(char *ch,char *s1,char *s2)
{
int n,mm,x,y;
int i,j,k,t;
n=strlen(ch);
mm=strlen(s1);
for(i=ii;i<=n-m;i++)
{
k=1;
for(j=i,t=0;tif(ch[j]!=s1[t])
{
k=0;
break;
}
if(k)
{
x=strlen(s2);
if(x<=mm)
{
for(j=i,t=0;tch[j]=s2[t];
for(t=mm+i;jch[j]=ch[t];
ch[j]='\0';
}
else
{
y=x-mm;
for(t=n-1;t>=mm+i;t--)
ch[t+y]=ch[t];
ch[n+y]='\0';
for(j=i,t=0;tch[j]=s2[t];
}
ii=i+strlen(s2);
break;
}
}
if(m!=1)
printf("\t\t替换成功!\n");
else
printf("\t\tReplace successfully!\n");
return ch;
}



void ReplaceString2(Article &head,char *s1,char *s2)//s2替换s1
{
Line *p=head;
int flag;
char c;
int i;
int mm=strlen(s1);
ii=0;
times=0;
while(p!=NULL)
{
flag=repjudge(p->data,s1);

if(flag)
{
if(m!=1)
printf("\t\t第%d次出现该字符串的所在行如下:\n",times);
else
printf("\t\tThe line that this string appears the %d time is:\n",times);
for(i=0;iprintf("%c",p->data[i]);
repprint(p->data,s1);
for(i=ii+mm;idata);i++)
printf("%c",p->data[i]);
printf("\n");
if(m!=1)
printf("\t\t是否要替换?\n\t\tY是,N否:");
else
printf("\t\tReplace or not?\n\t\tY to yes ,N to no:");
c=getchar(); getchar();
if(c=='Y'||c=='y')
strcpy(p->data,repstring2(p->data,s1,s2));
else
ii+=mm;
printf("\n");
if(m!=1)
printf("\t\t是否要继续替换?\n\t\tY是,N否:");
else
printf("\t\tContinue to replace?\n\t\tY to yes ,N to no:");
c=getchar();getchar(

);
if(c=='N'||c=='n')
break;
}
else
{
p=p->next;
ii=0;
}
}
if(m!=1)
printf("\t\t替换结束!\n");
else
printf("\t\tReplacing ends!\n");
}


void PrintArticle(Article head);


//删除和替换结束后是否输出删除后或替换后的文章
void IsPrint(int mm,Article head)
{
char ch;
if(mm==1)
{
if(m!=1)
printf("\t\t是否要输出续写后的文章?\n\t\tY是,N否:");
else
printf("\t\tDo you want to output the followed article?\n\t\tY to yes,N to no:");
ch=getchar();
if(ch=='Y'||ch=='y')
PrintArticle(head);
}
if(mm==2)
{
if(m!=1)
printf("\t\t是否要输出替换后的文章?\n\t\tY是,N否:");
else
printf("\t\tDo you want to output the replaced article?\n\t\tY to yes,N to no:");
ch=getchar();
if(ch=='Y'||ch=='y')
PrintArticle(head);
}
}




//替换管理模块
void replacemanage(Article &head,char *s1,char*s2)
{
int choice;
if(m!=1)
printf("\t\t1.全部替换\n\t\t2.部分替换\n\n\t\t请选择:");
else
printf("\t\t1.Replace all\n\t\t2.Replace sections\n\n\t\tPlease select:");
scanf("%d",&choice);
getchar();
if(choice==1)
ReplaceString1(head,s1,s2);
else
ReplaceString2(head,s1,s2);
}





void PrintArticle(Article head)
{
Line *p;
int n,i;
p=head;
if(head==NULL)
{
if(m!=1)
printf("\t\t该文章中没有内容!\n");
else
printf("\t\tThe article is empty!\n");
}
else
{
if(m!=1)
{ printf("\n\n\n ┎━━━━━━━━━━┒\n");
printf(" ┃ 该文章的内容如下 ┃\n");
printf(" ┖━━━━━━━━━━┚\n\n");
}
else
{
printf("\n\n\n ┎━━━━━━━━━━┒\n");
printf(" ┃ The article is ┃\n");
printf(" ┖━━━━━━━━━━┚\n\n");
}
}
while(p!=NULL)
{
n=strlen(p->data);
for(i=0;iprintf("%c",p->data[i]);
printf("\n");
p=p->next;
}
}




//追加模块
void CatchArticle(Article &head)
{
Line*p=head,*tail;
char ch[100];
if(m!=1)
printf("\t\t请输入要续写的文章内容(按ctrl+e结束):\n");
else
printf("\t\tPlease input the content following with the article(end with ctrl+e):\n");
if(head==NULL)
{
CreateArticle(head);
}
else
{
while(p->next!=NULL)
p=p->next;
tail=p;
while(1)
{
gets(ch);
p=(Line*)malloc(sizeof(Line));
p->next=NULL;
strcpy(p->data,ch);
if(p->data[strlen(p->data)-1]==5)
{
p->data[strlen(p->data)-1]='\0';
break;
}
tail->next=p;
tail=tail->next;
}
if(strlen(p->data)>0)
{
tail->next=p;
tail=tail->next;
}
}
}


void diaoshi();
void menu()
{
int i;
if(m!=1)
{
if(tt!=0)
{
printf("\n\n");
diaoshi();
printf("\n\n\n\

n");
}
for(i=1;i<=19;i++)printf("★☆");
printf("\n☆ ★");
printf("\n★ 这里是文章编辑系统 ☆");
printf("\n★ ☆\n");
for(i=1;i<=19;i++)printf("☆★");
printf("\n\n");
printf("\t\t¤1.新建文章\t\t");
printf("●2.读取文章\n");
printf("\t\t¤3.输出文章\t\t");
printf("●4.文章统计\n");
printf("\t\t¤5.文章编辑\t\t");
printf("●6.更改语言\n");
printf("\t\t¤7.选择颜色\t\t");
printf("●8.帮助说明\n");//关于系统使用的介绍说明及关于我们的团队介绍
printf("\t\t¤9.背景音乐");
printf("\t\t●0.返回\n");
printf("\n");
}
else
{
if(tt!=0)
{
printf("\n\n");
diaoshi();
printf("\n\n\n\n");
}
for(i=1;i<=19;i++)printf("☆★");
printf("\n★ ☆");
printf("\n☆ This is article editing system ★");
printf("\n☆ ★\n");
for(i=1;i<=19;i++)printf("★☆");
printf("\n\n");
printf("\t¤1.creat a new article\t\t");
printf("●2.read the article\n");
printf("\t¤3.output the article\t\t");
printf("●4.article statistic\n");
printf("\t¤5.edit the article\t\t");
printf("●6.change language\n");
printf("\t¤7.select color\t\t");
printf("●8.help(about)\n");
printf("\t¤9.background music\t\t");
printf("●0.exit\n");
}
}




void tongjimenu(Article head)
{
if(m!=1)
{
printf("\n\n\n ┎━━━━━━━━━━┒\n");
printf(" ┃ 统计结果如下 ┃\n");
printf(" ┖━━━━━━━━━━┚\n\n");
printf("\t\t\t文章中的字母数为:%d\n",CountLetter(head));
printf("\t\t\t文章中的空格数为:%d\n",CountSpace(head));
printf("\t\t\t文章中的数字数为:%d\n",CountFigure(head));
printf("\t\t\t文章中的汉字数为:%d\n",CountChinese(head));
printf("\t\t\t文章的总字数为:%d\n",CountArticle(head));
}
else
{
printf("\n\n\n ┎━━━━━━━━━━━━━━┒\n");
printf(" ┃ The statistical result is ┃\n");
printf(" ┖━━━━━━━━━━━━━━┚\n\n");
printf("\t\t\tthe number of letters is:%d\n",CountLetter(head));
printf("\t\t\tthe number of blank space is:%d\n",CountSpace(head));
printf("\t\t\tthe number of figures is:%d\n",CountFigure(head));
printf("\t\t\tthe number of Chinese is:%d\n",Coun

tChinese(head));
printf("\t\t\tthe number of the total words is:%d\n",CountArticle(head));
}
}

void editmenu()
{
if(m!=1)
{
printf("\n\n\n\t\t ┏━━━━━━━━━━━━━━━━━━━━┓\n");
printf("\t\t ┃ 文章编辑 ┃\n");
printf("\t\t ┗━━━━━━━━━━━━━━━━━━━━┛\n");
printf("\t\t / ┃ ┃ \\\n");
printf("\t\t / ┃ ┃ \\\n");
printf("\t\t ↙ ┃ ┃ ↘\n");
printf("\t\t ┏━━┓ ┏━━┓ ┏━━┓ ┏━━┓\n");
printf("\t\t ┃1、 ┃ ┃2、 ┃ ┃3、 ┃ ┃4、 ┃\n");
printf("\t\t ┃字符┃ ┃字符┃ ┃字符┃ ┃续写┃\n");
printf("\t\t ┃ 串 ┃ ┃ 串 ┃ ┃ 串 ┃ ┃ ┃\n");
printf("\t\t ┃统计┃ ┃删除┃ ┃替换┃ ┃文章┃\n");
printf("\t\t ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃\n");
printf("\t\t ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃\n");
printf("\t\t ┗━━┛ ┗━━┛ ┗━━┛ ┗━━┛\n\n");
printf("\t\t ●-● ●-● ●-● ●-●\n");
printf("\t\t ¤ ¤\n");
printf("\t\t ¤ 0、返回上层菜单 ¤\n");
printf("\t\t ¤ ¤\n");
printf("\t\t ●-● ●-● ●-● ●-●\n");
}
else
{
printf("\n\n\n\t\t ┏━━━━━━━━━━━━━━━━━━━━┓\n");
printf("\t\t ┃ edit the article ┃\n");
printf("\t\t ┗━━━━━━━━━━━━━━━━━━━━┛\n");
printf("\t\t / ┃ ┃ \\\n");
printf("\t\t / ┃ ┃ \\\n");
printf("\t\t ↙ ┃ ┃ ↘\n");
printf("\t\t ┏━━━━┓ ┏━━━━┓ ┏━━━━┓┏━━━━┓\n");
printf("\t\t ┃1、 ┃ ┃2、 ┃ ┃3、 ┃┃4、 ┃\n");
printf("\t\t ┃sum up ┃ ┃delete ┃ ┃replace ┃┃continue┃\n");
printf("\t\t ┃ ┃ ┃ ┃ ┃ ┃┃to write┃\n");
printf("\t\t ┃string ┃ ┃string ┃ ┃string ┃┃ the ┃\n");
printf("\t\t ┃ ┃ ┃ ┃ ┃ ┃┃ article┃\n");
printf("\t\t ┃ ┃ ┃ ┃ ┃ ┃┃ ┃\n");
printf("\t\t ┗━━━━┛ ┗━━━━┛ ┗━━━━┛┗━━━━┛\n\n");
printf("\t\t ●-● ●-● ●-● ●-● ●-● ●-●\n");
printf("\t\t ¤ ¤\n");
printf("\t\t ¤ 0、Return to the above menu ¤\n");
printf("\t\t ¤

¤\n");
printf("\t\t ●-● ●-● ●-● ●-● ●-● ●-●\n");
}
}



//文章编辑模块的实现
void editmanage(Article &head)
{
int choice;
Line *p=head;
char cc;
int num;
char s[100],s1[100],s2[100];
do
{
editmenu();
if(m!=1)
printf("\t\t请输入您的选择(若要返回上层菜单,请按0):");
else
printf("\t\tPlease input your choice(return to the above menu,please press 0):");
scanf("%d",&choice);
getchar();//在这里读入得好好处理一下,因为读入整型后就要读入一个字符型。。
if(choice<0||choice>4)
{
if(m!=1)
printf("\t\t输入错误,请重新输入!\n");
else
printf("\t\tInput error,please input again!\n");
}
else
{
switch(choice)
{
case 1:if(m!=1)
printf("\t\t请输入要统计的字符串(以回车结束):");
else
printf("\t\tPlease input a string to sum up(end with Enter):");
gets(s);
num=FindString(head,s);
if(num==0)
{
if(m!=1)
printf("\t\t文章中没有相应的字符串!\n");
else
printf("\t\tNo relevant string in the article!\n");
}
else
{
if(m!=1)
printf("\t\t文章中该字符串出现的次数为:%d\n",num);
else
printf("\t\tThe time of the string appears in the article is:%d\n",num);
}
break;
case 2:if(m!=1)
printf("\t\t请输入要删除的字符串(以回车结束):");
else
printf("\t\tPlease input a string to delete(end with Enter):");
gets(s);
num=FindString(head,s);
if(num==0)
{
if(m!=1)
printf("\t\t文章中没有相应的字符串!\n");
else
printf("\t\tNo relevant string in the article!\n");
}
else
{
deletemanage(head,s);
IsPrint(1,head);
SaveArticle(head);
}

break;
case 3://替代
if(m!=1)
printf("\t\t请输入要替换的字符串(以回车结束):");
else
printf("\t\tPlease input a string to replace(end with Enter):");
gets(s1);
if(m!=1)
printf("\t\t请输入要替换成的字符串(以回车结束):");
else
printf("\t\tPlease input a string to replace the above string(end with Enter):");
gets(s2);
num=FindString(head,s1);
if(num==0)
{
if(m!=1)
printf("\t\t文章中没有相应的字符串!\n");
else
printf("\t\tNo relevant string in the article!\n");
}
else
{
replacemanage(head,s1,s2);
IsPrint(2,head);
SaveArticle(head);
}
break;
case 4://追加
CatchArticle(head);
if(m!=1)
printf("\t\t文章已经被更改。。是否保存?\n\t\tY是,N否:");
else
printf("\t\tThe article has been changed...

Do you want to save it?\n\t\tY to yes ,N to no:");
cc=getchar();
if(cc=='Y'||cc=='y')
{
SaveArticle(head);
getchar();
IsPrint(1,head);
}
else
ReadFile(head);
case 0:break;
}
}
}while(choice);
}



//更改语言
void ChangeLanguage()
{
m=(!m);
}



//音乐模块
void closemusic(int k)
{
if(k==1)
{
mciSendString("close ok1.mp3",0,0,0);
}
if(k==2)
{
mciSendString("close ok2.mp3",0,0,0);
}
if(k==3)
{
mciSendString("close ok3.mp3",0,0,0);
}
if(k==4)
{
mciSendString("close ok4.mp3",0,0,0);
}
if(k==5)
{
mciSendString("close ok5.mp3",0,0,0);
}
}

void playmusic()
{
if(music==1)
{
mciSendString("open ok1.mp3",0,0,0);
mciSendString("play ok1.mp3",0,0,0);
}
if(music==2)
{
mciSendString("open ok2.mp3",0,0,0);
mciSendString("play ok2.mp3",0,0,0);
}
if(music==3)
{
mciSendString("open ok3.mp3",0,0,0);
mciSendString("play ok3.mp3",0,0,0);
}
if(music==4)
{
mciSendString("open ok4.mp3",0,0,0);
mciSendString("play ok4.mp3",0,0,0);
}
if(music==5)
{
mciSendString("open ok5.mp3",0,0,0);
mciSendString("play ok5.mp3",0,0,0);
}
}

void musicmenu()
{
if(m!=1)
printf("\n\t\t选择音乐:\n");
else
printf("\n\t\tplease select background music:\n");
printf("\n\t\t1、那些年\n");
printf("\n\t\t2、到底为什么\n");
printf("\n\t\t3、有一种爱叫做放手\n");
printf("\n\t\t4、青春纪念册\n");
printf("\n\t\t5、倔强\n");
printf("\n\t\t6、关闭音乐\n");
printf("\n\t\t0、返回\n");
if(m!=1)
printf("\n\t\t请选择:");
else
printf("\n\t\tplease select:");
}

void Music()
{
int k;

do
{

if(music>0&&music<6)
k=music;
musicmenu();
scanf("%d",&music);


if(music&&(music>0&&music<6))
{ closemusic(k);
playmusic();
}
else if(music==6)
closemusic(k);
else
{

if(music>6||music<0)
{
if(m!=1)
printf("\t\t输入错误!请重新输入!\n");
else
printf("\t\tInput error!please input again!\n");
music=k;
}
}
}while(music);
music=k;

}





//界面模块
void diaoshi()//调用系统时间函数
{
struct tm *newtime;

time_t long_time;
time( &long_time ); /* Get time as long integer. */
newtime = localtime( &long_time ); /* Convert to local time. */

printf( "当前系统时间:【%.19s】\n", asctime( newtime ) );
}


void logprint()
{
int i;
printf("\n\n\n\n\n\t\t\t 正在登录系统,请稍候...\n\n\n\n\t\t\t\t");
for(i=0;i<5;i++)
{
printf(".");
_sleep(300);
}
system("cls");
}


void LoginPrint()
{
int i;
for(i=0;i<5;i++)
{
logprint();
}
}

void LoginPrint2()
{
system("color 31");
printf("\n\n\n\n\n\n\t▂ ▃ ▄ ▅ ▆ ▇ ██ ☆ ██ ▇ ▆ ▅ ▄ ▃ ▂\n");
pr

intf("\t▂ ▃ ▄ ▅ ▆ ▇ ██ ★ 欢迎 ★ ██ ▇ ▆ ▅ ▄ ▃ ▂\n");
printf("\t▂ ▃ ▄ ▅ ▆ ▇ ██ ☆ 登陆 ☆ ██ ▇ ▆ ▅ ▄ ▃ ▂\n");
printf("\t▂ ▃ ▄ ▅ ▆ ▇ ██★ 文章编辑 ★██ ▇ ▆ ▅ ▄ ▃ ▂\n");
printf("\t▂ ▃ ▄ ▅ ▆ ▇ ██ ☆ 系统 ☆ ██ ▇ ▆ ▅ ▄ ▃ ▂\n");
printf("\t▂ ▃ ▄ ▅ ▆ ▇ ██ ★ ★ ██ ▇ ▆ ▅ ▄ ▃ ▂\n");
printf("\t▂ ▃ ▄ ▅ ▆ ▇ ██ ☆ ██ ▇ ▆ ▅ ▄ ▃ ▂\n");
printf("\n\n\n\t ");
_sleep(200);printf("制");_sleep(200);printf("作");_sleep(200);printf("团队");_sleep(200);printf(":");_sleep(200);printf("计");_sleep(200);printf("机");_sleep(200);printf("5");
_sleep(200);printf(" ");_sleep(200);printf("C");_sleep(200);printf("_");_sleep(200);printf("Y");_sleep(200);printf("_");_sleep(200);printf("F");
printf("\n\n");
printf("\t ");
_sleep(200);printf("团");_sleep(200);printf("队");_sleep(200);printf("成");_sleep(200);printf("员");_sleep(200);printf(": ");_sleep(200);printf("陈");_sleep(200);printf("楚");_sleep(200);printf("燕");
printf("\n\t ");
_sleep(200);printf(" 陈");_sleep(200);printf("友");_sleep(200);printf("煌");
printf("\n\t ");
_sleep(200);printf(" 刘");_sleep(200);printf("凤");_sleep(200);printf("娇");
_sleep(3000);
system("color 07");
printf("\n");
}



void AboutPrint()
{
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_RED | FOREGROUND_GREEN);
char c[12][10]={"color 1","color 2","color 5","color 6","color 9","color a","color b","color c","color d","color e","color f"};
system("cls");
printf("\n\n\n\n\n");
printf("\t\t\t 文章编辑系统V1.01\n");
printf("\t\t\t*********************************\n");
printf("\t\t\t* 2010级计算机科学与技术5班 *\n");
printf("\t\t\t* C_Y_F *\n");
printf("\t\t\t* *\n");
printf("\t\t\t* Email:*********@https://www.doczj.com/doc/8f6369825.html, *\n");
printf("\t\t\t* QQ:********* *\n");
printf("\t\t\t* 版权没有 翻版不究*\n");
printf("\t\t\t* 咨询热线:陈楚燕:652765 *\n");
printf("\t\t\t* 陈友煌:691203 *\n");
printf("\t\t\t* 刘凤娇:644190 *\n");
printf("\t\t\t*********************************\n");
int x=100*rand();
int i=x+30;
for(;x{
_sleep(10);
printf(">>>>");
system(c[x%11]);
x%2==0?Beep(1000,50):1;
}
printf("\n\n使用说明:\n");
printf("\t是不是在苦思用什么系统来编辑您的文章更便捷呢?也是不是在犹豫有哪些文章编辑系统能够提供轻松愉悦的工作环境呢?\n");
printf("\t抑或是正在搜罗着哪个文章编辑系统拥有强大的功能

而让您大展鸿鹄之志呢?是,就恭喜您来对了地方!\n");
printf("\t本系统拥有较为强大的功能,可以实现新建文章、读取文章、文章统计、文章编辑、更改语言、选择颜色等常用功能。\n");
printf("\n\n团队介绍:\n");
printf("\tC_Y_F团队是由来自10计算机科学与技术5班的陈楚燕、陈友煌、刘凤娇三位同学志同道合而创建的,\n");
printf("\t\t其旨意在于打造功能齐备的文章编辑系统。\n");
printf("\n\t\t任意键返回主菜单...");
getch();
}

//退出界面
void ExitPrint()
{
system("cls");
printf("\n\n\n\n\n\t\t※●※●※●※●※●※●※\n");
printf("\t\t● 谢谢 ●\n");
printf("\t\t※ 使用此文章 ※\n");
printf("\t\t● 编辑 ●\n");
printf("\t\t※ 系统!!! ※\n");
printf("\t\t● 再见!!! ●\n");
printf("\t\t※●※●※●※●※●※●※\n\n");
}


int main()
{
int choice;
Article head=NULL;
system("color 4a");
LoginPrint();
system("color 07");
LoginPrint2();
system("cls");
diaoshi();
printf("\n\n\n o(∩_∩)o欢迎使用\"计机5 C_Y_F\"为您精心打造的文章编辑系统o(∩_∩)o\n\n\n\n");
do
{
menu();tt++;
if(m!=1)
printf("\t\t请输入您的选择(若要退出,请按0):");
else
printf("\t\tPlease input your choice(exit,please press 0):");
scanf("%d",&choice);getchar();
if(choice<0||choice>9)
{
if(m!=1)
printf("\t\t输入错误,请重新输入!\n");
else
printf("\t\tInput error,please input again!\n");
}
else
{
switch(choice)
{
case 1:CreateArticle(head);
IsSave(head);
break;
case 2:ReadFile(head);
break;
case 3:PrintArticle(head);
break;
case 4:tongjimenu(head);
break;
case 5:system("cls");
editmanage(head);
system("cls");
break;
case 6:ChangeLanguage();
break;
case 7:system("cls");color();system("cls");
break;
case 8://关于
system("cls");AboutPrint();getchar();system("cls");restorecolor();
break;
case 9:system("cls");Music();system("cls");
break;
case 0:break;
}
}
}while(choice);
ExitPrint();
return 0;
}



相关主题
文本预览
相关文档 最新文档