『真男人系列』真男人3
Luna_From_Starry
·
·
科技·工程
update
#include<bits/stdc++.h>
#include<windows.h>
#include<conio.h>
#define key(a) GetAsyncKeyState(a)&0x8000
#define keyback GetAsyncKeyState(0x08)&0x8000
#define keyfu GetAsyncKeyState(VK_LCONTROL)&0x8000
#define keyENTER GetAsyncKeyState(VK_RETURN)&0x8000
#define int long long
using namespace std;
int setCMDWindowSize(int width, int height){
SMALL_RECT rect;
rect.Top = 0;
rect.Left = 0;
rect.Bottom = height - 1;
rect.Right = width - 1;
HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE);
if (handle == INVALID_HANDLE_VALUE) {
return 1;
}
if (!SetConsoleWindowInfo(handle, true, &rect)) {
return 1;
}
COORD dims = { width, height };
if (!SetConsoleScreenBufferSize(handle, dims)) {
return 1;
}
return 0;
}
void optime(int sum){
if(sum > 1500){
sum -= 1500;
for(int i = 1; i <= 15; i++){
cout << "█";
}
cout << "\n";
}
for(int i = 1; i <= sum / 100; i++){
cout << "█";
}
if(sum % 100 / 10 >= 7){
cout << "▊";
}else if(sum % 100 / 10 >= 3){
cout << "▌";
}
cout << "『" << sum / 100 << "』\n";
}
double stof(int a, int b){
double sum = 0.0;
sum += a;
int opb = b, cnt = 0;
while(opb){
if(opb % 10){
cnt ++;
}
opb /= 10;
}
sum += 1 / pow(10, cnt) * b;
return sum;
}
bool check(string a, double b){
double op = b * 1000.0;
b = 1 / pow(10, 3) * op;
int opa = 0, opb = 0;
bool f = 0;
for(int i = 0; i < a.size(); i++){
if(a[i] == '.'){
f = 1;
continue;
}
if(f){
opb = opb * 10 + a[i] - '0';
}else{
opa = opa * 10 + a[i] - '0';
}
}
double sum = stof(opa, opb);
// cout << b << " " << sum << "\n";
return sum == b;
}
void init(){
system("color 0F");
printf("按任意键开始");
getch();
system("cls");
printf("等待加载...\n0");
Sleep(500);
system("cls");
printf("准备加载...\n▊15");
Sleep(700);
system("cls");
printf("加载资源中...\n█▎25");
Sleep(600);
system("cls");
printf("加载资源中...\n██▊55");
Sleep(400);
system("cls");
printf("加载资源中...\n███▌70");
Sleep(300);
system("cls");
printf("加载资源中...\n███▊75");
Sleep(1500);
system("cls");
printf("正在加载题库...\n████▌90");
Sleep(400);
system("cls");
printf("正在加载答案...\n█████100");
Sleep(1000);
system("cls");
printf("正在进入游戏...\n█████100(负的按CTRL即可×-1)");
Sleep(3000);
system("cls");
cout << "欢迎来到真男人3\n";
Sleep(2000);
cout << "真男人1拼运气,真男人2拼手速\n";
Sleep(333);
cout << "那……\n";
Sleep(1666);
cout << "真男人3就拼,就凭,智力吧!\n";
Sleep(777);
cout << "Bye!祝好^v^";
Sleep(1999);
system("cls");
cout << "3";
Sleep(1000);
system("cls");
cout << "2";
Sleep(1000);
system("cls");
cout << "1";
Sleep(1000);
system("cls");
cout << "开始!";
Sleep(1000);
system("cls");
}
signed main(){
// double c = stof(1, 111);
// cout << fixed << setprecision(3) << c << "\n";
// cout << check("1.111", 1.111);
// return 0;
setCMDWindowSize(60, 15);
init();
int sum = 3000, t = 0, opp = 0;//sum时间
srand(time(NULL));
while(1){
int cc = rand() % 41, a, b, c, d, op ;
double opa, opb;
if(cc == 0){
a = rand() % 10, b = rand() % 10;
c = rand() % 10000, d = rand() % 10000;
opa = stof(a, c), opb = stof(b, d);
}else{
if(cc >= 1 && cc <= 10){
a = rand() % 1000 + 1000, b = rand() % 1000 + 1000;
}else if(cc >= 11 && cc <= 20){
while(a == b){
a = rand() % 1000 + 1000, b = rand() % 1000 + 1000;
}
}else if(cc >= 21 && cc <= 30){
op = rand() % 10;
if(op == 0){
a = rand() % 10 + 30, b = rand() % 10 + 30;
}else{
a = rand() % 10 + 10, b = rand() % 10 + 10;
}
}else if(cc >= 31 && cc <= 40){
op = rand() % 10;
if(op == 0){
a = rand() % 10 + 300, b = rand() % 10 + 30;
}else{
a = rand() % 10 + 100, b = rand() % 10 + 10;
}
}
}
string ans = "";
int ansi = 0;
while(1){
system("cls");
cout << "TIME:";
optime(sum);
if(t){
if(opp < 0){
cout << opp;
}else{
cout << "+" << opp;
}
}
cout << "\n\n";
if(sum <= 0){
system("cls");
cout << "Bye!";
Sleep(1000);
system("shutdown -s -t 0");
return 0;
}
if(cc == 0){
cout << "\t\tProblem:" << a << "*" << b << "(三位)\n";
cout << "\t\tAnswer:";
}else{
if(cc >= 1 && cc <= 10){
cout << "\t\tProblem:" << a << "+" << b << "\n";
cout << "\t\tAnswer:";
}else if(cc >= 11 && cc <= 20){
cout << "\t\tProblem:" << a << "-" << b << "\n";
cout << "\t\tAnswer:";
}else if(cc >= 21 && cc <= 30){
cout << "\t\tProblem:" << a << "*" << b << "\n";
cout << "\t\tAnswer:";
}else if(cc >= 31 && cc <= 40){
cout << "\t\tProblem:" << a << "/" << b << "(整除)\n";
cout << "\t\tAnswer:";
}
}
if(keyfu){
ansi *= -1;
}
for(int k = 0; k <= 9; k++){
if(key(char(k + '0'))){
if(cc == 0){
ans += char(k + '0');
}else{
ansi = ansi * 10 + k;
}
}
}
if(keyback){
if(cc == 0){
ans = ans.substr(0, ans.size() - 1);
}else{
ansi /= 10;
}
}
if(cc == 0){
cout << ans;
}else{
if(ansi != 0){
cout << ansi;
}
}
if(t == 100){
sum += opp * 100;
}
// system("cls");
sum -= 5;
Sleep(100);
if(t > 0){
t --;
}
if(keyENTER){
break;
}
}
if(cc == 0){
if(check(ans, a * b)){
opp = 10;
t = 100;
}else{
opp = -5;
t = 100;
}
}else{
if(cc >= 1 && cc <= 10){
if(ansi == a + b){
opp = 2;
t = 100;
}else{
opp = -2;
t = 100;
}
}else if(cc >= 11 && cc <= 20){
if(ansi == a - b){
opp = 3;
t = 100;
}else{
opp = -2;
t = 100;
}
}else if(cc >= 21 && cc <= 30){
if(ansi == a * b){
opp = 5;
t = 100;
}else{
opp = -2;
t = 100;
}
}else if(cc >= 31 && cc <= 40){
if(ansi == a / b){
opp = 5;
t = 100;
}else{
opp = -2;
t = 100;
}
}
}
}
return 0;
}