抽单词
来水个帖。
想用的随便拿~
$s$数组存单词,$s1$存翻译,下标要一样(太菜了只能这么做qwq)
#define KEY_DOWN(VK_NONAME) ((GetAsyncKeyState(VK_NONAME) & 0x8000) ? 1:0)
#include<bits/stdc++.h>
#include<windows.h>
using namespace std;
typedef pair<int,int> PII;
const int N = 100010;
vector<string> s={};
vector<string> s1={};
vector<string> res;
vector<PII> test;
vector<int> situation;
char w[30]={'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'};
char W[30]={'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'};
int len=s.size();
void work();
bool check_mouse(int lx,int x,int x1,int ly,int y,int y1)
{
if(lx>=x&&lx<=x1&&ly>=y&&ly<=y1)
return true;
return false;
}
bool check_test(int u)
{
int l=test.size();
for(int i=0;i<l;i++)
if(u==test[i].first)return false;
return true;
}
void startt()
{
//while(//check_mouse())
CONSOLE_CURSOR_INFO info = { 1, 0 };
HANDLE hand = GetStdHandle(STD_OUTPUT_HANDLE);
COORD coord = { 0, 0 };
POINT pt = { 0, 0 };
SetConsoleCursorInfo(hand, &info); //设置光标属性
while(true)
{
system("color F4");
cout<<"点击此处进入应用";
SetConsoleCursorPosition(hand, coord);
GetCursorPos(&pt);
bool f=false;
long long cnt=0;
while(check_mouse(pt.x,0,200,pt.y,45,60))
{
cnt++;
SetConsoleCursorPosition(hand, coord);
GetCursorPos(&pt);
f=true;
if(cnt==1)
{
system("cls");
system("color F1");
cout<<"点击此处进入应用";
}
else if(cnt>0x7f7f7f7f7f)cnt=2;
if(KEY_DOWN(VK_LBUTTON))return;
}
if(f)system("cls");
}
}
void word()
{
string ans;
srand(time(NULL));
int u=rand() % len;
while(!check_test(u))
{
srand(time(NULL));
u=rand() % len;
}
srand(time(NULL));
int v=rand() % 2;
test.push_back({u,v});
if(v)
{
cout<<"题目:"<<s[u]<<endl;
cout<<"答案:";
cin>>ans;
if(ans==s1[u])cout<<"exellent",situation.push_back(1);
else cout<<"sorry!"<<endl<<"正确答案是"<<s1[u],situation.push_back(0),res.push_back(ans);
}
else
{
cout<<"题目:"<<s1[u]<<endl;
cout<<"答案:";
cin>>ans;
if(ans==s[u])cout<<"fantastic!",situation.push_back(1);
else cout<<"no no no!"<<endl<<"正确答案是"<<s[u],situation.push_back(0),res.push_back(ans);
}
}
void examination()
{
cout<<"请输入单词数:";
int T=0x3f3f3f3f;
while(T>len)
{
cin>>T;
if(T>len)
{
cout<<"大于当前单词数,请重新输入。"<<endl;
Sleep(1000);
cout<<"请输入单词数:";
}
}
Sleep(1000);
system("cls");
while(T--)
{
word();
if(T) Sleep(2500);
system("cls");
}
int t=0,f=0;
int ss=situation.size();
for(int i=0;i<ss;i++)
if(situation[i])t++;
else f++;
cout<<"结果:"<<endl<<"对:"<<t<<endl<<"错:"<<f<<endl<<endl;
cout<<"错题:"<<endl<<"题目"<<setw(10)<< "正确答案 "<<setw(10)<<"你的答案"<<endl;
for(int i=0;i<ss;i++)
{
if(!situation[i])
{
if(test[i].second)cout<<s[test[i].first]<<setw(10)<<s1[test[i].first]<<setw(10)<<res[i]<<endl;
else cout<<s1[test[i].first]<<setw(10)<<s[test[i].first]<<setw(10)<<res[i]<<endl;
}
}
test.clear();
}
void query_words()
{
for(int i=0;i<26;i++)
{
cout<<"以"<<w[i]<<"或"<<W[i]<<"为首字母:"<<endl;
bool f=false;
for(int j=0;j<len;j++)
{
char u=s[j][0];
if(u==w[i])cout<<setw(10)<<s[j],f=true;
}
for(int j=0;j<len;j++)
{
char u=s[j][0];
if(u==W[i])cout<<setw(10)<<s[j],f=true;
}
if(!f)cout<<"空"<<endl;
cout<<endl;
}
}
void back()
{
cout<<"按666(任意键)返回首界面"<<endl;
string ss;
cin>>ss;
system("cls");
work();
}
bool check_choose(int u)
{
if(u<=2)return true;
return false;
}
void work()
{
startt();
system("cls");
system("color F8");
cout<<"欢迎来到抽单词!"<<endl;
Sleep(1000);
cout<<"目前单词数:"<<len<<endl;
cout<<"1.抽单词 2.查看单词表"<<endl<<"选择:";
int s=0;
cin>>s;
while(!check_choose(s))
{
cout<<"选择无效,重新选择。"<<endl<<"选择:";
cin>>s;
}
if(s==1)
{
examination();
back();
}
else if(s==2)
{
query_words();
back();
}
}
int main()
{
work();
return 0;
}
有什么建议也能提.
膜拜。