1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
| #include<bits/stdc++.h> using namespace std;
inline int read(){int x=0,f=1;char ch=getchar(); while(ch<'0'||ch>'9'){if(ch=='-')f=-1; ch=getchar();}while(ch>='0'&&ch<='9'){x=(x<<1)+ (x<<3)+(ch^48);ch=getchar();}return x*f;} #define Z(x) (x)*(x)
int n, m, i, j, k, T; string c[20]={"1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20"}; string s[20]={"氢", "氦", "锂", "铍", "硼", "碳", "氮", "氧", "氟", "氖", "钠", "镁", "铝", "硅", "磷", "硫", "氯", "氩", "钾", "钙"}; string t[20]={"H", "He", "Li", "Be", "B", "C", "N", "O", "F", "Ne", "Na", "Mg", "Al", "Si", "P", "S", "Cl", "Ar", "K", "Ca"}; string str;
int rd(int x, int u, int v) { if(u==v) return x; int y; do{ y=rand()%20; }while(y==x); return y; }
void wen(string c[20], string s[20]) { cout<<"请问 " << c[i] << " 对应的是:" << endl; n=rand()%4; cout<<"A. "<< s[rd(i, n, 0)] << " "; cout<<"B. "<< s[rd(i, n, 1)] << " "; cout<<"C. "<< s[rd(i, n, 2)] << " "; cout<<"D. "<< s[rd(i, n, 3)] << " ";
cout<<endl; }
signed main() {
srand(time(NULL)); cout<< "请开启大写锁定" << endl; while(1) { k=rand()%6; i=rand()%20; if(k==0) wen(c, s); if(k==1) wen(c, t); if(k==2) wen(s, c); if(k==3) wen(s, t); if(k==4) wen(t, c); if(k==5) wen(t, s); cin>>str; j=str[0]-'A'; if(j==n) cout<<"恭喜你 ,答对了!"<<endl; else cout<<"答案错误... 正确答案为:" << (char)(n+'A') << endl; } return 0; }
|