資源簡介
自己做的C++課程設計大作業 visual studio2010 開發 附源代碼 能運行 采用文件存儲信息 有單詞復習,修改錄入 單詞游戲 單詞測驗等功能 希望對大家有用
代碼片段和文件信息
#include?“recite.h“
struct?words?*?creatlist(int?buser&?a)????????????????????????????????????//讀取詞庫文件創建鏈表
{
words?*s*p=NULL;
words?*head?=NULL;
fstream?zzc;
if?(b==1)
{
zzc.open(a.wordfile_nameios::in|ios::out);
????if(!zzc)
???cout<<“Word?file?could?not?be?open?“< }
else
{
zzc.open(a.wrongwordfile_nameios::in|ios::out);
????if(!zzc)
???cout<<“Wrong?word?file?could?not?be?open?“< }
???s=?new?words;
???zzc?>>?s->en?>>?s->ch;
???s->en[sizeof(s->en)-1]=‘\0‘;
???s->ch[sizeof(s->ch)-1]=‘\0‘;
???while(!zzc.eof())
????{
if(head==NULL)??
head?=?s;
else
p->next=?s;
p=s;
s=?new?words;
zzc>>s->en>>s->ch;??????????????????????????????????????//把中英文錄入結點
s->en[sizeof(s->en)-1]=‘\0‘;
????s->ch[sizeof(s->ch)-1]=‘\0‘;
????}
???p->next?=?s;
???p?=?s;
???p->next?=?NULL;
???????zzc.close();
???return?head;
}
struct?users?*?creatlist()????????????????????????????????????//讀取用戶信息文件創建鏈表
{
????users?*s*p=NULL;
users?*head?=NULL;
fstream?zzc;
zzc.open(“f:\\users.dat“ios::in|ios::out|ios::binary);
if(!zzc)
??????cout<<“File?users.txt?could?not?be?open?“< ????s=?new?users;
zzc?>>?s->na?>>?s->pa;
while(!zzc.eof())
????{
if(head==NULL)??
head?=?s;
else
p->next=?s;
p=s;
s=?new?users;
zzc>>?s->na?>>?s->pa;?????????????????????????????????????
????}
p->next?=?s;
p?=?s;
p->next?=?NULL;
zzc.close();
return?head;
}
void?showlist(words?*head)?????????????????????????????????????????//遍歷鏈表
{???
?????while(head)
??????????{
???????????cout<en<<“\t\t“<ch< ???????????head?=?head->next;
??????????}
}?????????????????????????????????????
void?writefile(struct?words?*headuser?&uint?b)??????????????????????????????//將單詞鏈表寫入文檔
{
struct?words?*p;
ofstream?zeller;
if(b==1)
zeller.open(u.wordfile_name);
else
zeller.open(u.wrongwordfile_name);
p=head;
while(p!=NULL)
{
zeller.write(p->enstrlen(p->en));
zeller.put(‘?‘);
zeller.write(p->chstrlen(p->ch));
zeller.put(‘\n‘);
p=p->next;
}
delete?phead;
zeller.close();
}
void?writefile(struct?users?*head)??????????????????????????????//將用戶鏈表寫入文檔
{
struct?users?*p;
ofstream?zeller;
zeller.open(“f:\\users.txt“);
p=head;
while(p!=NULL)
{
zeller.write(p->nastrlen(p->na));
zeller.put(‘?‘);
zeller.write(p->pastrlen(p->pa));
zeller.put(‘\n‘);
p=p->next;
}
delete?phead;
zeller.close();
}
int?fileexist_judge()?????????????????????????????????????????????????????????????//判斷用戶信息文件是否存在
{
?ifstream?file;
?file.open(“f:\\users.dat“ios::binary|ios::in);
?????if(!file)
?return?0;
?else
?return?1;
}
int?wordexist_judge(int?a?user?&?u)????????????????????????????????????//判斷詞庫中有無單詞
{
fstream?zzc;
if?(a==1)
{
zzc.open(u.wordfile_nameios::in|ios::out);
????if(!zzc)
???cout<<“Word?file?could?not?be?open?“<
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件?????145920??2012-09-01?10:21??背單詞\Debug\背單詞.exe
?????文件????2071400??2012-09-01?10:21??背單詞\Debug\背單詞.ilk
?????文件????1289216??2012-09-01?10:21??背單詞\Debug\背單詞.pdb
?????文件???48037888??2012-09-02?15:49??背單詞\ipch\背單詞-966a95d4\背單詞-b751a47a.ipch
?????文件??????????1??2009-08-31?02:32??背單詞\背單詞\ClassDiagram1.cd
?????文件???????1286??2012-09-01?10:21??背單詞\背單詞\Debug\cl.command.1.tlog
?????文件??????37104??2012-09-01?10:21??背單詞\背單詞\Debug\CL.read.1.tlog
?????文件????????644??2012-09-01?10:21??背單詞\背單詞\Debug\CL.write.1.tlog
?????文件??????????2??2012-09-01?10:21??背單詞\背單詞\Debug\li
?????文件??????????2??2012-09-01?10:21??背單詞\背單詞\Debug\li
?????文件??????????2??2012-09-01?10:21??背單詞\背單詞\Debug\li
?????文件??????????2??2012-09-01?10:21??背單詞\背單詞\Debug\li
?????文件??????????2??2012-09-01?10:21??背單詞\背單詞\Debug\li
?????文件??????????2??2012-09-01?10:21??背單詞\背單詞\Debug\li
?????文件??????????2??2012-09-01?10:21??背單詞\背單詞\Debug\li
?????文件??????????2??2012-09-01?10:21??背單詞\背單詞\Debug\li
?????文件??????????2??2012-09-01?10:21??背單詞\背單詞\Debug\li
?????文件??????????2??2012-09-01?10:21??背單詞\背單詞\Debug\li
?????文件??????????2??2012-09-01?10:21??背單詞\背單詞\Debug\li
?????文件??????????2??2012-09-01?10:21??背單詞\背單詞\Debug\li
?????文件??????????2??2012-09-01?10:21??背單詞\背單詞\Debug\li
?????文件??????????2??2012-09-01?10:21??背單詞\背單詞\Debug\li
?????文件??????????2??2012-09-01?10:21??背單詞\背單詞\Debug\li
?????文件??????????2??2012-09-01?10:21??背單詞\背單詞\Debug\li
?????文件??????????2??2012-09-01?10:21??背單詞\背單詞\Debug\li
?????文件??????????2??2012-09-01?10:21??背單詞\背單詞\Debug\li
?????文件??????????2??2012-09-01?10:21??背單詞\背單詞\Debug\li
?????文件??????????2??2012-09-01?10:21??背單詞\背單詞\Debug\li
?????文件??????????2??2012-09-01?10:21??背單詞\背單詞\Debug\li
?????文件??????????2??2012-09-01?10:21??背單詞\背單詞\Debug\li
............此處省略93個文件信息
評論
共有 條評論