当前位置:首页 » 编程语言 » 字典上有没有C语言代码
扩展阅读
webinf下怎么引入js 2023-08-31 21:54:13
堡垒机怎么打开web 2023-08-31 21:54:11

字典上有没有C语言代码

发布时间: 2022-09-13 00:19:11

c语言 密码字典

楼上的兄弟不适合做程序员,自私!
楼主,12位的密码你知道有多少了吗?这数据量非常大,程序我是写出来了,10位还能用文本打开,但是到了12位就打不开了,120多M的txt,反正我电脑打开的时候就卡死了!有疑问网络找我!
其实程序很简单。
#include "stdio.h"
#include "conio.h"
#include "stdlib.h"

int main()
{
/*to char +48*/
FILE *f;
char a[13];
int i1,i2,i3,i4,i5,i6,i7,i8;
f= fopen("C:\\mima.txt","wt+");
printf("create...\n ");
a[0] = 'l';
a[1] = 'X';
a[2] = '1';
a[3] = 'v';
a[112] = '\n';
for(i1=0;i1<10;i1++)
{
a[4]=i1+48;
for(i2=0;i2<10;i2++)
{
a[5]=i2+48;
for(i3=0;i3<10;i3++)
{
a[6]=i3+48;
for(i4=0;i4<10;i4++)
{
a[7]=i4+48;
for(i5=0;i5<10;i5++)
{
a[8]=i5+48;
for(i6=0;i6<10;i6++)
{
a[9]=i6+48;
for(i7=0;i7<10;i7++)
{
a[10]=i7+48;
for(i7=0;i7<10;i7++)
{
a[11]=i8+48;
fwrite(a,13,1,f);
}
}
}
}
}
}
}
}
fclose(f);
printf("success!\n");
getch();
}

Ⅱ python中有C语言吗

1.C语言是编译语言,Python是脚本语言。说是C语言会比Python快
2.list和数组
C语言中的数组,里面的都是数字,而list中可以包含很多不同的数据元素。
2.import和include
在C语言中使用那个库函数,需要引入头文件用include引入,而在python中需要引入别的模块或者函数时需要用import引入。
两者的不同机制是,C语言中include是告诉预处理器,这个include指定的文件的内容,要当作本地源文件出现过,而python中的import可以通过简单的import
导入,或者是 import numpy as np
3.全局变量方面
在C语言中,声明全局变量,如果值是恒定的,那么可以直接用#define声明,如果只是声明全局,并且变量的值是可变的,那么直接类似int a
就可以了,在python中,声明全局变量时,需要加上global,类似global a,在函数里面使用的时候需要先声明global a
,否则直接用a那么python会重新创建一个新的本地对象并将新的值赋值给他,原来的全局变量的值并不变化

Ⅲ 跪求关于词典检索的c语言程序 帮帮忙啊!!!!!!!

原型:
int WINAPI icePub_dictionaryCodeTransfer2(char *strDictionaryFilename,char *strSrc,char *strCode,char *strFenge)
输入:strDictionaryFilename 字典文件名
strSrc 待处理单词
strFenge 字典里单词和code之间的分隔符字符串
输出:strCode strSrc对应信息
返回码:

char strCode[1024];
typedef int (WINAPI ICEPUB_DICTIONARYCODETRANSFER2)(char *strDictionaryFilename,char *strSrc,char *strCode,char *strFenge);
ICEPUB_DICTIONARYCODETRANSFER2 *icePub_dictionaryCodeTransfer2 = 0;
HINSTANCE hDLLDrv = LoadLibrary("icePubDll.dll");
if(hDLLDrv)
{
icePub_dictionaryCodeTransfer2 = (ICEPUB_DICTIONARYCODETRANSFER2 *)GetProcAddress(hDLLDrv, "icePub_dictionaryCodeTransfer2");
}

if(icePub_dictionaryCodeTransfer2)
icePub_dictionaryCodeTransfer2("汉英字典.txt","我",strCode, " ");

if(hDLLDrv)
FreeLibrary(hDLLDrv);
AfxMessagBox(strCode);

Ⅳ 急急急!!!!用c语言实现字典 要求:用无序双向循环链表实现字典的基本操作如下

#include <stdafx.h> //这行是VC编译时要的头文件,你若TC就不要本行了
#include <stdio.h>

typedef struct dictnode{char *key; char *value; dictnode *pre; dictnode *next;} DictNode;

DictNode *pHead = NULL;

//(1)make:构造空的字典
int make()
{
if(pHead)return -1;
pHead = (DictNode*)malloc(sizeof(DictNode));
memset(pHead,0,sizeof(DictNode));
pHead->pre = pHead;
pHead->next = pHead;
return 0;
}

//(2)size:返回字的字典中记录数
int size()
{
int i;
DictNode*p;
for(i=0,p=pHead; p->next!=pHead; p=p->next,i++);
return i;
}

//(3)IsEmpy:如果字典为空则返回真,否则返回假
int IsEmpy()
{
return (pHead->pre==pHead);
}

//(4)Clear:将字典重置为空
void Clear()
{
DictNode* p,*ptmp;
for(p=pHead->next; p!=pHead ; )
{
ptmp = p;
p = p->next;
free(ptmp->key);
free(ptmp->value);
free(ptmp);
}
pHead->next = pHead->pre = pHead;//最后一个空节点也是第一个节点
}

//(5)Insert:插入记录到字典
int Insert(char *key,char*value)
{
DictNode* p, *ptmp;
if(!key||!value||!*key||!*value) return -100;//调用错误
ptmp = (DictNode*)malloc(sizeof(DictNode));
if(!ptmp) return -2; //内存不足这种极端的情况很难出现,但有可能
memset(ptmp,0,sizeof(DictNode));
ptmp->key =(char*) malloc(strlen(key)+1);
if(!ptmp->key){free(ptmp);return -2;} //内存不足这种极端的情况很难出现,但有可能
strcpy(ptmp->key,key);
ptmp->value = (char*)malloc(strlen(value)+1);
if(!ptmp->value){free(ptmp->key);free(ptmp); return -2;} //内存不足这种极端的情况很难出现,但有可能
strcpy(ptmp->value,value);
for(p=pHead->next; p->next!=pHead; p=p->next) if(p->key&&!strcmp(p->key,key)) return 1;//记录存在,插入失败
ptmp->next = pHead; pHead->pre = ptmp;
ptmp->pre = p; p->next = ptmp;
return 0;//操作成功返回0
}

//(6)remove:与给定关键字的记录相同则删除,该记录被返回,否则字典保持不变
DictNode* remove(char *key)
{
DictNode* p;
for(p=pHead->next; p!=pHead&&strcmp(p->key,key); p=p->next);
if(p==pHead) return NULL;
p->pre->next = p->next;
p->next->pre = p->pre;
p->pre = p->next = NULL;
return p;//结点p的空间(key value p三个)没有释放,外面要接收返回值并主动释放结点空间或做别的处理如插入另一表中等
}

//(7)IsPrensent:如果存在与给定关键字匹配的记录则返回真,否则返回假
int IsPrensent(char *key)
{
DictNode* p;
for(p=pHead->next; p!=pHead&&strcmp(p->key,key); p=p->next);
return (p!=pHead);
}

//(8)Find:如果存在与给定关键字相同的记录,则返回记录;如果没有找到,则返回空
DictNode* Find(char *key)
{
DictNode* p;
for(p=pHead->next; p!=pHead&&strcmp(p->key,key); p=p->next);
if(p==pHead) return NULL;
return p; //不要对Find返回的记录key值做变更,value值可以修改,value加长时要重新分配空间。因为记录还在字典链表中
}

void main()
{
const char *prtstr = "****************************";
DictNode* ptmp;
char keybuf[80];
char valuebuf[1024];
int c;
make();
while(1)
{
system("cls");//清屏
printf("%s 选择菜单 %s",prtstr,prtstr);
printf("\n\tF---词条查找\n\tI---插入新词条\n\tR---删除词条\n\tC---清空字典\n\tS---显示字典词条数\n\tQ---退出\n");
printf("请选择操作菜单:");
fflush(stdin);
c = getchar();
if(c>='a'&&c<='z') c -= ('a'-'A');//换大写
if(c!='F'&&c!='I'&&c!='R'&&c!='C'&&c!='S'&&c!='Q') continue;
fflush(stdin);
switch(c)
{
case 'F':
printf("词条查找:\n请输入Key值:");scanf("%s",keybuf);
fflush(stdin);
ptmp = Find(keybuf);
if(ptmp){printf("Key:%s Value:%s",ptmp->key,ptmp->value);}
else{printf("没找到词条:%s,你可以先选择插入这个新词条",keybuf);}
break;
case 'I':
printf("插入新词条:\n请输入Key值:");scanf("%s",keybuf);
fflush(stdin);
if(IsPrensent(keybuf)){printf("词条%s已存在\n",keybuf);}
else
{
printf("请输入它的解释:");gets(valuebuf);
if(!Insert(keybuf,valuebuf))printf("插入成功\n");
else printf("插入失败\n");
}
break;
case 'R':
printf("删除词条:\n请输入Key值:");scanf("%s",keybuf);
fflush(stdin);
ptmp = remove(keybuf);
if(ptmp)
{
free(ptmp->value);free(ptmp->key);free(ptmp);
printf("记录key:[%s]已删除\n",keybuf);
}
else
printf("未找到待删除的记录key:[%s]\n",keybuf);
break;
case 'C':
printf("清空字典:\n真的要清吗?\n请输入Yes以确认删除操作(首字母大写):");scanf("%s",keybuf);
fflush(stdin);
if(strcmp(keybuf,"Yes")){printf("放弃了清空操作\n");}
else {Clear();printf("Ok,你坚持操作,现在字典已清空了\n");}
break;
case 'S':
printf("显示字典词条数:\n当前词条总数:%d\n", size());
break;
case 'Q':
Clear(); free(pHead);
printf("Byebye");
exit(0);
}
printf("\n按回车键继续......");
fflush(stdin);
getchar();
}
}
//VC7.1 下调试通过,运行功能正常

Ⅳ 求一个实现简单的英汉词典(30词左右)c++的C语言程序

字典最快速的实现方法是trie tree。
这个树是专门用来实现字典的。但是trie tree的删除操作比较麻烦。用二叉查找树可以实现,速度也可以很快。AVL tree只不过是平衡的二叉树,在字典这个应用上没有客观的速度提升,因为字典不会产生极端化的二叉树(链表)。
下面是我的二叉查找树的代码。二叉查找树的优点是实现容易,而且它的inorder traverse既是按照字母顺序的输出。
//binary search tree, not self-balancing

//by Qingxing Zhang, Dec 28,2009. prep for google interview

#include <iostream>
using namespace std;

struct BST
{
int data;
BST *left;
BST *right;
};

//runtime: O(logn) on average, O(n) worst case
bool search(BST *&root, int key)//return false if the key doesn't exist
{
if(root==NULL)
return false;
if(key < root->data)
return search(root->left,key);
else if(key > root->data)
return search(root->right,key);
else
return true;
}

//runtime: O(logn)on average, O(n) worst case
bool insert(BST *&root, int key)//return false if the key already exists
{
if(root==NULL)
{
BST *node = new BST;
node->data = key;
node->left = node->right = NULL;
root = node;
return true;
}
else if(key < root->data)
return insert(root->left,key);
else if(key > root->data)
return insert(root->right,key);
else
return false;
}

//runtime:O(logn) on average, O(n) worst case
bool remove(BST *&root,int key)//return false if the key doesn't exist.
{
if(root==NULL)//no such key
return false;
else if(key < root->data)
return remove(root->left,key);
else if(key > root->data)
return remove(root->right,key);
else//node found
{
if((root->left==NULL)&&(root->right==NULL))//no child(leaf node)
{
BST *tmp = root;
root = NULL;
delete tmp;
}
else if((root->left==NULL)||(root->right==NULL))//one child
{
BST *tmp = root;
if(root->left==NULL)
root = root->right;
else
root = root->left;
delete tmp;
}
else//two children:replace node value with inorder successor and delete that node
{
BST *tmp = root->right;
while(tmp->left!=NULL)
tmp = tmp->left;
int tmpdata = tmp->data;
remove(root,tmpdata);
root->data = tmpdata;
}
return true;
}
}
//runtime:O(n)
void inorder(BST *&node)
{
if(node!=NULL)
{
inorder(node->left);
cout << node->data << " ";
inorder(node->right);
}
}
//runtime:O(n)
void preorder(BST *&node)
{
if(node!=NULL)
{
cout << node->data << " ";
preorder(node->left);
preorder(node->right);
}
}
//runtime:O(n)
void postorder(BST *&node)
{
if(node!=NULL)
{
postorder(node->left);
postorder(node->right);
cout << node->data << " ";
}
}

int main()
{
bool b;
BST *root = NULL;
b = insert(root,1);
b = insert(root,3);
b = insert(root,7);
b = insert(root,5);
b = insert(root,77);
b = insert(root,10);
b = insert(root,4);
b = insert(root,13);

//inorder
cout << "In-order:";
inorder(root);
cout << endl;
//preorder
cout << "Pre-order:";
preorder(root);
cout << endl;
//postorder
cout << "Post-order:";
postorder(root);
cout << endl;
// search for 7
if(search(root,7))
cout << "7 found!" << endl;
else
cout << "7 doesn't exist!" << endl;

b = remove(root,7);
cout << "----------------" << endl;

//inorder
cout << "In-order:";
inorder(root);
cout << endl;
//preorder
cout << "Pre-order:";
preorder(root);
cout << endl;
//postorder
cout << "Post-order:";
postorder(root);
cout << endl;

if(search(root,7))
cout << "7 found!" << endl;
else
cout << "7 doesn't exist!" << endl;

return 0;
}

Ⅵ 急!!十万火急!!!高手的来!关于数据结构中字典的实现,C语言代码:用无序循环单链表实现以下操作!

printarray(b,lenth);
printf("\n");
free(a);
free(b);
return 0;
}
void inputarray(int*a,int n){
for(int j=0;j<n;j++)
scanf("%d",&a[j]);
}
void exchange(int*a,int*b,int n){
for(int j=0;j<n;j++)
swap(a+j,b+j);
}
void swap(int* a,int* b){
int c;
c=*a;
*a=*b;
*b=c;
}
void printarray(int* a,int n){
for(int j=0;j<n;j++)
printf("%d,",a[j]);

Ⅶ C语言实现字典序排列的代码问题

一般的排序是从0位置开始,即从数组第一个元素开始排序。
你这段代码是从第n+1个数据开始排序,仅此而已

Ⅷ 需要会C语言的各位大佬帮忙写一个简单的词典小代码

有偿的 30元 一天写完

Ⅸ C语言简单的英文词典排版系统的实现

#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<ROWS&&scanf("%s", a[i])==1) { fflush(stdin); if(strncmp(a[i],"END",3)==0) { count+=i; break; } if(check(a[i], i)) continue; i++; } } puts("您要做些什么?"); puts("a. 显示已有的单词 b. 添加新单词"); puts("c. 对已有的单词进行排序 d. 退出"); while((input=get_option())!='d') { if(input=='a') { puts("已有的单词:"); for(i=0;i<count;i++) { printf(" "); puts(a[i]); } } if(input=='b') { puts("请输入新的单词(每行一个),在新行输入END结束输入: "); count=b(count); } if(input=='c') { puts("对单词进行排序:"); c(pt, count); for(i=0;i<count;i++) { printf(" "); puts(pt[i]); } } puts("还要做些什么?"); } storage(pt,count); fclose(fp); puts("再见!"); return 0; } char get_option(void) { char ch; while((ch=getchar())<'a'||ch>'d') { while((ch=getchar())!='\n') ; puts("请输入a,b,c或者d."); } fflush(stdin); return ch; } int b(int count) { int i; i=count; while(i<ROWS&&scanf("%s", a[i])==1) { fflush(stdin); if(check(a[i], i)) continue; if(strncmp(a[i],"END",3)==0) { count=i; break; } i++; } return count; } void c(char *pt[], int count) { int i,j; char *temp; for(i=0;i<ROWS;i++) pt[i]=a[i]; for(i=0;i<count;i++) for(j=i+1;j<count;j++) { if(strcmp(pt[i],pt[j])>0) { 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<strlen(arr);i++) if(isalpha(arr[i])==0) { printf("%s不是一个单词.\n",arr); flag=1; break; } for(i=0;i<count;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<count;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); }

Ⅹ 运用c语言编写一个英汉字典~ 谢谢啦~先

原型:
int WINAPI icePub_dictionaryCodeTransfer2(char *strDictionaryFilename,char *strSrc,char *strCode,char *strFenge)
输入:strDictionaryFilename 字典文件名
strSrc 待处理单词
strFenge 字典里单词和code之间的分隔符字符串
输出:strCode strSrc对应信息
返回码:

原型:
int WINAPI icePub_dictionaryAddRecord(char *strDictionaryFilename,char *strSrc,char *strCode,char *strFenge)
输入:strDictionaryFilename 字典文件名
strSrc 待添加单词(如果存在则替换)
strCode strSrc对应信息
strFenge 字典里单词和code之间的分隔符字符串
输出:
返回码:

原型:
int WINAPI icePub_dictionaryDelRecord(char *strDictionaryFilename,char *strSrc,char *strFenge)
输入:strDictionaryFilename 字典文件名
strSrc 待删除单词
strFenge 字典里单词和code之间的分隔符字符串
输出:
返回码:

网络一个《icepubdll揭秘》有详细说明