一种简单英文词典排版系统的实现 C语言编程
答案:2 信息版本:手机版
解决时间 2019-10-06 18:43
已解决
2019-10-06 03:21
1. 一种简单的英语词典排版系统的实现
[要求]
(1) 能输入和显示打入的单词.
(2) 能分辨出单词.
(3) 对重复的单词和已输入的单词能自动排除.
(4) 能按A~Z的顺序排版.
(5) 能将结果以文本形式存储.
(6) 具有添加新单词并重新排版的能力.
[提示]
(1) 需求分析:运行结果以文本形式存储,因而要提供文件的输入输出操作;通过查找操作检查重复单词;提供排序操作实现按A~Z的顺序排版;提供插入操作添加新单词并重新排版.另外通过键盘式菜单实现功能选择.
(2) 总体设计:整个系统被设计为单词录入模块、文件存储模块和单词浏览模块.其中单词录入模块要完成输入单词、检查是否重复、排序操作.文件存储模块把存放单词的数组中的数据写入文件.单词浏览模块完成英文单词的输出,即文件的输出操作.
(3) 数据结构采用指针数组或二维数组.以[Enter]键或者空格键作为单词输入结束标志,对重复的单词自动排除可选用查找方法,数据结构可采用指针和数组.
最佳答案
2019-10-06 04:04
#include "stdio.h"
#include "stdlib.h"
#include "string.h"
#include "ctype.h"
#define ROWS 256
#define COLS 32
static FILE *fp;
static char a[ROWS][COLS];
char get_option(void);
int b(int count);
void c(char *pt[], int count);
int check(char arr[], int count);
void storage(char *pt[], int count);
int main(void)
{
int i,count;
int start;
char *pt[ROWS];
char ch, len;
char input;
if((fp=fopen("words.txt","a+"))==NULL)
{
fputs("不能打开或建立文件!\n",stderr);
exit(1);
}
fseek(fp,0L,SEEK_END);
start=(int)ftell(fp)/32;
count=start;
rewind(fp);
if(fread(a,32*sizeof(char),start,fp)==0)
{
i=0;
puts("请输入单词(每行一个),在新行输入END结束输入:");
while(i'd')
{
while((ch=getchar())!='\n')
;
puts("请输入a,b,c或者d.");
}
fflush(stdin);
return ch;
}
int b(int count)
{
int i;
i=count;
while(i0)
{
temp=pt[i];
pt[i]=pt[j];
pt[j]=temp;
}
}
}
int check(char arr[], int count)
{
int i;
int flag=0;
for(i=0;i
if(isalpha(arr[i])==0)
{
printf("%s不是一个单词.\n",arr);
flag=1;
break;
}
for(i=0;i
if(strncmp(a[i],a[count],strlen(a[count])+1)==0)
{
puts("重复的单词!");
flag=1;
}
return flag;
}
void storage(char *pt[], int count)
{
int i,j;
char ptr[ROWS][COLS];
c(pt, count);
for(i=0;i
for(j=0;pt[i][j]!='\0';j++)
ptr[i][j]=pt[i][j];
fp=fopen("words.txt","w+");
rewind(fp);
fwrite(ptr,32*sizeof(char),count,fp);
}
全部回答
1楼
2019-10-06 04:49
#include
#include
typedef struct _word
{
int id;
char str[10];
struct _word* next;
}word;
word* dict_create()
{
word* p = (node*)malloc(sizeof(word));
return p;
}
int dict_insert(word* list, word* node)
{
//add your code here
return 0;
}
int dict_edit(word* list, int index, word* node)
{
//add your code here
return 0;
}
int dict_del(word* list, int index)
{
//add your code here
return 0;
}
int dict_search(word* list, char* str)
{
int count = -1;
//add your code here
return count;
}
int dict_print(word* list)
{
//add your code here
return 0;
}
int dict_sort(word* list)
{
//add your code here
return 0;
}
我要举报
如果感觉以上信息为低俗/不良/侵权的信息,可以点下面链接进行举报,我们会做出相应处理,感谢你的支持!
大家都在看
推荐资讯