本文目录一览:
如何用c语言做一个简单的英语词典
//新建一个字典文本文件,命名为:dict.dat,内容格式如下: 或下载一个也可
//abandon v.抛弃,放弃
//abandonment n.放弃
//abbreviation n.缩写
//abeyance n.缓办,中止
//abide v.遵守
//ability n.能力
//able adj.有能力的,能干的
//abnormal adj.反常的,变态的
//aboard adv.船(车)上
//abolish v.废除,取消
//******************************
#include stdio.h
#include stdlib.h
#include string.h
struct NODE
{
char e[20];
char c[50];
struct NODE* pnext;
};
struct NODE* pN;
struct NODE* pHead=NULL;
struct NODE* pNode=NULL;
struct NODE* pNext=NULL;
struct NODE* pEnd=NULL;
FILE* open_dict()
{
FILE *fp;
if((fp=fopen("dict.dat","r"))==NULL)
{
printf("open dict error!\n");
return NULL;
}
return fp;
}
int getdata_from_dict(FILE* fp)
{
int i,j;
char buf[50];
while(1)
{
pN=(struct NODE*)malloc(sizeof(struct NODE));
memset(pN-c,'\0',50);
memset(pN-e,'\0',20);
pN-pnext=NULL;
if(fgets(buf,50,fp)==NULL)
{
fclose(fp);
break;
}
sscanf(buf,"%s %s",pN-e,pN-c);
if(pHead==NULL)
{
pHead=pN;
pNode=pN;
continue;
}
pNode-pnext=pN;
pNode=pN;
pEnd=pN;
}
return 1;
}
void write_dict()
{
FILE* fp=NULL;
if((fp=fopen("dict.dat","w"))==NULL)
{
printf("open dict error!\n");
return;
}
char buf[100]={'\0'};
pNode=pHead;
while(1)
{
if(pNode==NULL)
{
break;
}
fprintf(fp,"%s %s\n",pNode-e,pNode-c);
pNode=pNode-pnext;
}
fclose(fp);
}
void del(char* char_del)
{
struct NODE* pDel=pHead;
if(strcmp(pDel-e,char_del)==0)
{
pHead=pHead-pnext;
write_dict();
return ;
}
while(1)
{
if(strcmp(pDel-pnext-e,char_del)==0)
{
if(pDel-pnext-pnext!=NULL)
{
pDel-pnext=pDel-pnext-pnext;
}
else
{
pDel-pnext=NULL;
}
write_dict();
return ;
}
else
{
pDel=pDel-pnext;
if(pDel==NULL)
{
break;
}
}
}
printf("\n未找到该单词!\n");
return;
}
void add(char* char_add, char* char_add_chs)
{
pN=(struct NODE*)malloc(sizeof(struct NODE));
memset(pN-c,'\0',50);
memset(pN-e,'\0',20);
pN-pnext=NULL;
strcpy(pN-e,char_add);
strcpy(pN-c,char_add_chs);
pEnd-pnext=pN;
pEnd=pN;
pNode=pN;
write_dict();
}
int main(int argc, char *argv[])
{
FILE* fp=NULL;
fp=open_dict();
if(fp==NULL)
{
printf("读取字典失败! 程序将退出!");
getchar();
return 1;
}
getdata_from_dict(fp);
fclose(fp);
char buf[50]={'\0'};
while(1)
{
printf("\n\n{输入quit: 即退出, 输入del: 即删除, 输入add: 即增加}\n请输入英文单词 : ");
fflush(stdin);
scanf("%s",buf);
if(strcmp(buf,"quit:")==0)
{
break;
}
else if(strcmp(buf,"del:")==0)
{
char char_del[20]={'\0'};
printf("请输入要删除的单词:");
fflush(stdin);
scanf("%s",char_del);
del(char_del);
continue;
}
else if(strcmp(buf,"add:")==0)
{
char char_add[20]={'\0'};
char char_add_chs[100]={'\0'};
printf("\n请输入要增加的单词:");
fflush(stdin);
scanf("%s",char_add);
printf("\n请输入中文意思:");
fflush(stdin);
scanf("%[^\n]",char_add_chs);
add(char_add,char_add_chs);
continue;
}
pNode=pHead;
int find=0;
while(pNode!=NULL)
{
if(strcmp(pNode-e,buf)==0)
{
printf("\n%s",pNode-c);
find=1;
break;
}
pNode=pNode-pnext;
}
if(find==0)
{
printf("\n未找到!");
}
}
return 0;
}
c语言编程 输出密码字典
改为这样吧!
简洁明了!
#includestdio.h
int main()
{
int a,b,c;
for(a=0;a=9;a++)
for(b=0;b=9;b++)
for(c=0;c=9;c++)
printf("%d%d%d\t",a,b,c);
}
#includestdio.h
int main()
{
int c;
char m,b;
for(m='a';m='a'm='z';m++)
for(b='A';b='A'b='Z';b++)
for(c=0;c=9;c++)
printf("%c%c%d\t%c%c%d\t%d%c%c\t%d%c%c\t%c%d%c\t%c%b%c\n",m,b,c,b,m,c,c,m,b,c,b,m,b,c,m,m,b,c);
}
你试一下吧,这样做的话,每一次都输出一个组合。
c语言做出的程序都能干什么?一般黑客编写的入侵和攻击程序用的是什么语言?
C语言最大的应用就是写操作系统和驱动程序还有其他嵌入式系统的程序,学习程序设计选选择C是很好的,掌握的一定程度再学C++,java等就容易一些.
黑客工具的开发语言很多了,用java好像没听说,很多小工具是直接用的汇编,小榕暴强的扫描工具"流光"是C++ Builder开发的,现在很多菜鸟黑客甚至用中文编程语言(易语言)来开发一些工具软件.