www.pudn.com > bdc.rar > bdc.cpp
#include#include #include #include #include #include class word{ private: int level; public: char eword[20]; char trans[200]; char method[200]; char sentence[200]; int showlevel(){ return level; } void levelup(int r){ level++; if (level>r){level=r;} } void leveldown(int r){ level--; if (level >words[i].eword; if (words[i].eword[0]>='A'&&words[i].eword[0]<='z'){ strcpy(words[i].eword,strlwr(words[i].eword)); } else{ i--; destruct=1; } } file.getline(buf,sizeof(buf)); } else if(buf[0]=='('){ sTemp[0]=buf[1];sTemp[1]=buf[2];sTemp[2]='\0'; last=0; if (!strcmp(sTemp,"英")){ strcpy(words[i].trans,strcat(buf,"\0")); last=1; } else if(!strcmp(sTemp,"记")){ strcpy(words[i].method,strcat(buf,"\0")); last=2; } else if(!strcmp(sTemp,"例")){ strcpy(words[i].sentence,strcat(buf,"\0")); last=3; } file.getline(buf,sizeof(buf)); } else if(buf[0]!='\n'){ if (last==1){ strcat(words[i].trans,buf); } else if(last==2){ strcat(words[i].method,buf); } else if(last==3){ strcat(words[i].sentence,buf); } file.getline(buf,sizeof(buf)); last=0; } } js=0; return i; } } file.close(); return 1; } int recordlog(int sum,int n){ int i; ofstream ofile(user,ios::app); ofile<<"+"; struct tm *newtime; time_t long_time; time( &long_time ); newtime = localtime( &long_time ); ofile<<'\t'<<((newtime->tm_year-100)*365+newtime->tm_yday)<<'\t'< 0){ ofile< >rd; if (rd=='+'){ ofile>>yday; ofile>>list; } if (list!=n){ while (list!=n||!ofile.eof()){ ofile>>rd; if (rd=='+'){ ofile>>yday; ofile>>list; break; } } } ofile<<'\t'<<(rtime+1); ofile< >eword; for (i=1;i<=sum;i++){ if(!strcmp(words[i].eword,eword)){ ofile<<'\t'< >eword; } } ofile.close(); return 0; } int recite(int sum,int r){ int i; char ch='0'; char mark; cout< 0&&words[i].showlevel()>=r)){ mark='1'; cout<>ch; if (ch=='y'){ recite(sum,r+1); } return 1; } int review(){ wordsformat(); fstream mfile(user,ios::in|ios::out); int oblivion[6]={1,1,2,3,5,10}; int i; char rd; int yday; int rtime; int daynow; int list; int sum; int level; char buf[30]; while(!mfile.eof()){ mfile>>rd; if (rd=='+'){ mfile>>yday; mfile>>list; mfile>>rtime; { struct tm *newtime; time_t long_time; time( &long_time ); newtime=localtime( &long_time ); daynow=(newtime->tm_year-100)*365+newtime->tm_yday; } if ((yday+oblivion[rtime])<=daynow){ if (rtime==4){ cout<<"建议先把书看一遍."< >buf; while(buf[0]!='-'){ for (i=1;i<=sum;i++){ if (!strcmp(words[i].eword,buf)){ mfile>>level; words[i].setlevel(level); i=sum; } } if (mfile.eof()){ cout<<"复习完了!"< >buf; } recite(sum,rtime+1); recordlog2(sum,list,rtime); } mfile.getline(buf,sizeof(buf)); } } cout<<"今日没有需要复习的."< >list; if (list==0){file>>list;} file.close(); return list; } char* encode(char* psw){ int i; char key[11]="sphinxshen"; for (i=0;i<20;i++){ if (psw[i]!=NULL){ psw[i]=psw[i]+key[i%10]; } } return psw; } char* decode(char* psw){ int i; char key[11]="sphinxshen"; for (i=0;i<20;i++){ if (psw[i]!=NULL){ psw[i]=psw[i]-key[i%10]; } } return psw; } int reg(){ char* id=new char[20]; char* tempid=new char[20]; char* psw=new char[20]; cout<<"新人来这里:"< >id; ifstream rfile("users.inf"); if (!strcmp(id,"new")){ rfile.close(); delete[] id; delete[] tempid; delete[] psw; return 0; } else{ while(!rfile.eof()){ rfile>>tempid; if(!strcmp(tempid,id)){ cout<<"对不起,名花有主了,请另觅芳草!"< >psw; psw=encode(psw); fstream wfile("users.inf",ios::app); wfile< >tempid; if(!strcmp(tempid,id)){ rfile>>temppsw; temppsw=decode(temppsw); if (!strcmp(temppsw,psw)){ rfile.close(); delete[] tempid; delete[] temppsw; return 1; } else{ return 0; } } } delete[] tempid; delete[] temppsw; return -1; } char* login(){ char* id=new char[20]; char* psw=new char[20]; int ck=0; cout<<"用户登陆"< >id; if (!strcmp(id,"new")){ while (ck==0){ ck=reg(); } } else{ cout<<"密码:"; cin>>psw; ck=checkpsw(id,psw); delete[] psw; if (ck==1){ return id; } else if(ck==0){ cout<<"密码错误!"<