#include <iostream.h>
#include <fstream.h>
#include <string.h>
#include <iomanip.h>
#include <stdio.h>
#include <time.h>
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<r){level=r;}
}
void setlevel(int l){
level=l;
}
word(){
level=0;
}
};
word* words=new word[200];
char user[20];
int wordsformat(){
int i;
for (i=1;i<200;i++){
words[i].setlevel(0);
words[i].eword[0]='\0';
words[i].method[0]='\0';
words[i].sentence[0]='\0';
words[i].trans[0]='\0';
}
return 1;
}
int chooselist(int n){
char thelist[49]={'1','2','3','4','5','6','7','8','9','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','A','B','C','D','E','F','G','H','I','J','K','L','M','N'};
ifstream file("gre.txt");
if (!file){
cout << "file open error!"<<endl;
return 0;
}
int i=0;
int js=0;
char sTemp[3];
int last=0;
int destruct=0;
char buf[500];
wordsformat();
while(!file.eof()){
if (js==0){
file.getline(buf,sizeof(buf));
if (buf[0]=='+'){
if (buf[1]==thelist[n-1]){
js=1;
file.getline(buf,sizeof(buf));
cout<<"LIST"<<thelist[n-1]<<endl;
}
}
}
else if(js==1){
while(buf[0]!='+'){
if (buf[0]=='\0'||destruct==1){
last=0;
if (buf[0]=='\0'){
destruct=0;
i++;
strcpy(words[i].trans,"no");
strcpy(words[i].method,"no");
strcpy(words[i].sentence,"no");
file>>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'<<n<<'\t'<<0<<endl;
for (i=1;i<=sum;i++){
if(words[i].showlevel()>0){
ofile<<words[i].eword<<'\t'<<words[i].showlevel()<<endl;
}
}
ofile<<'-'<<endl;
ofile.close();
cout<<"初记完了!"<<endl;
fstream mfile(user,ios::in|ios::out);
if ((n+1)<10){
mfile<<0<<(n+1);
}
else{
mfile<<n+1;
}
mfile.close();
return 0;
}
int recordlog2(int sum,int n,int rtime){
char rd;
int yday;
int list;
int i;
fstream ofile(user,ios::in|ios::out);
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<<endl;
char eword[20];
ofile>>eword;
for (i=1;i<=sum;i++){
if(!strcmp(words[i].eword,eword)){
ofile<<'\t'<<words[i].showlevel()<<endl;
ofile>>eword;
}
}
ofile.close();
return 0;
}
int recite(int sum,int r){
int i;
char ch='0';
char mark;
cout<<sum<<endl;
for (i=1;i<=sum;i++){
if (r==0||(r>0&&words[i].showlevel()>=r)){
mark='1';
cout<<i<<"."<<words[i].eword<<endl;
while((ch = getchar()) != EOF && ch != '\n'){mark=ch;}
if (mark=='a'){
cout<<"难度系数加一"<<endl;
words[i].levelup(5);
}
else if (mark=='d'){
cout<<"难度系数减一"<<endl;
words[i].leveldown(r);
}
cout<<"难度系数"<<words[i].showlevel()<<endl<<endl;
if (strcmp(words[i].trans,"no")){
cout<<words[i].trans<<endl;
}
if (strcmp(words[i].method,"no")){
cout<<"----------------"<<endl;
cout<<words[i].method<<endl;
}
if (strcmp(words[i].sentence,"no")){
cout<<"----------------"<<endl;
cout<<words[i].sentence<<endl;
}
cout<<endl<<endl<<endl;
if(mark=='b'){
i-=2;
if (i<1){i=1;}
}
}
}
cout<<"再复习一遍吗?(y to process)"<<endl;
cin>>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<<"建议先把书看一遍."<<endl;
}
cout<<list<<endl;
sum=chooselist(list);
mfile>>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<<"复习完了!"<<endl;
mfile.close();
return 1;
}
mfile.getline(buf,sizeof(buf));
mfile>>buf;
}
recite(sum,rtime+1);
recordlog2(sum,list,rtime);
}
mfile.getline(buf,sizeof(buf));
}
}
cout<<"今日没有需要复习的."<<endl;
mfile.close();
return 1;
}
int getlist(){
ifstream file(user);
int list;
file>>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<<"新人来这里:"<<endl;
cout<<"请留下芳名:";
cin>>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<<"对不起,名花有主了,请另觅芳草!"<<endl;
rfile.close();
delete[] id;
delete[] tempid;
delete[] psw;
return 0;
}
}
}
rfile.close();
cout<<"密码:";
cin>>psw;
psw=encode(psw);
fstream wfile("users.inf",ios::app);
wfile<<id<<"\t"<<psw<<"\n"<<endl;
wfile.close();
fstream mfile(strcat(id,".log"),ios::app);
mfile<<"01"<<endl;
mfile.close();
delete[] id;
delete[] tempid;
delete[] psw;
return 1;
}
int checkpsw(char* id,char* psw){
char* tempid=new char[20];
char* temppsw=new char[20];
ifstream rfile("users.inf");
while(!rfile.eof()){
rfile>>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];
bdc.rar_BDC_bdc背_背单词_背单词程序_艾宾浩斯
版权申诉
24 浏览量
2022-09-20
13:31:01
上传
评论
收藏 3KB RAR 举报
alvarocfc
- 粉丝: 105
- 资源: 1万+
最新资源
- onenet_chongwukanhu_v06.apk
- 2022NOC软件创意编程赛项真题C++初中-决赛(有解析)
- 2022NOC软件创意编程赛项真题python初中-决赛(有解析)
- openLayer-本地数据加载 (day5)
- A题-正弦信号发生器.xdf
- 2022NOC软件创意编程赛项真题python小学高年级-决赛(有解析)
- mathml转换latex需要的xsl文件
- 2022NOC软件创意编程赛项真题图形化小学高年级-决赛(有解析)
- gbase驱动下载gbase-connector-java-8.3.81.53驱动下载
- 2022NOC软件创意编程赛项真题图形化小学低年级-决赛(有解析)
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
评论0