#include<bits/stdc++.h>\nusing namespace std;\n__int128 a,b,ans;int c;\ninline __int128 read(){\n\t__int128 x=0;int f=1;\n\tchar c=getchar();\n\twhile(!isdigit(c)) if(c=='-') f=-1,c=getchar();\n\twhile(isdigit(c)) x=(x<<3)+(x<<1)+(c^48),c=getchar();\n\treturn xf;\n}\nvoid write(__int128 x){\n\tif(x<0) putchar('-'),x=-x;\n\tif(x>9) write(x/10);\n\tputchar(x%10|'0');\n}\nint main(){\n\twhile(puts("Please press the 0 and the enter key to end the game and press the 1 or 2 and press the enter key to select the mode."),scanf("%d",&c),c){\n\t\tsrand(time(nullptr));\n\t\tif(c!=1&&c!=2){\n\t\t\tputs("The key which is pressed isn't the 1 or 2.");\n\t\t\treturn 0;\n\t\t}\n\t\tswitch(c){\n\t\t\tcase 1:\n\t\t\t\ta=rand()%1145+1;\n\t\t\t\tb=rand()%1145+1;\n\t\t\t\twrite(a);\n\t\t\t\tputchar('');\n\t\t\t\twrite(b);\n\t\t\t\tputs("=?");\n\t\t\t\tans=read();\n\t\t\t\t__int128 user_ans=read();\n\t\t\t\tif(user_ans==ans) puts("You are clever.");\n\t\t\t\telse puts("RUSB?");\n\t\t\t\tbreak;\n\t\t\tcase 2:\n\t\t\t\ta=rand()%25+1;\n\t\t\t\tb=rand()%25+1;\n\t\t\t\twrite(a);\n\t\t\t\tputchar('^');\n\t\t\t\twrite(b);\n\t\t\t\tputs("=?");\n\t\t\t\tans=read();\n\t\t\t\t__int128 user_ans=read();\n\t\t\t\tif(user_ans==ans) cout<<"You are clever.\n";\n\t\t\t\telse cout<<"RUSB?\n";\n\t\t\t\tbreak;\n\t\t}\t\n\t}\n\treturn 0;\n}\n

C++ 128 位整数运算实现的简单算术游戏

原文地址: https://www.cveoy.top/t/topic/pWCT 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录