Добавил:
korayakov
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз:
Предмет:
Файл:Лабы / С++.ЭТМО / 1 - Lexemy / Lab3-1
.cpp#include <iostream.h>
#include <string.h>
#include "strList.h"
StList Lex[10];
int h1(char *x)
{
// return ((strlen(x) + x[0])%10);
return ((x[0]+x[strlen(x)-1])%10);
}
void al(char *x)
{
Lex[h1(x)].Add(x);
}
void addAllLexems()
{
al("asm");
al("auto");
al("bool");
al("break");
al("case");
al("catch");
al("char");
al("class");
al("const");
al("const_cast");
al("continue");
al("default");
al("delete");
al("do");
al("double");
al("dynamic_cast");
al("else");
al("enum");
al("explict");
al("export");
al("extern");
al("false");
al("float");
al("for");
al("friend");
al("goto");
al("if");
al("inline");
al("int");
al("long");
al("mutable");
al("namespase");
al("new");
al("operator");
al("private");
al("protected");
al("public");
al("register");
al("reinterpret_cast");
al("return");
al("short");
al("signed");
al("sizeof");
al("static");
al("static_cast");
al("struct");
al("switch");
al("template");
al("this");
al("throw");
al("true");
al("try");
al("typedef");
al("tipeid");
al("typename");
al("union");
al("unsigned");
al("using");
al("virtual");
al("void");
al("volatile");
al("wchar_t");
al("while");
}
void main()
{
int x;
char st[20];
addAllLexems();
cout<<"Enter the word and you will see all lexems of language"<<endl<<"whose HASH is equal: ";
cin>>st;
Lex[h1(st)].PrnStList();
cin>>x;
}
Соседние файлы в папке 1 - Lexemy