也是只用两分半就把这个做出来了
难度巨大!!!(笑)
#include <bits/stdc++.h>
#include <iostream>
#include <time.h>
#include <stdlib.h>
#include <cmath>
#include <windows.h>
#include <cstdlib>
#include <cstdio>
#include <stdio.h>
using namespace std;
int T;
int table[10], ans[10];
bool f = true;
int main() {
srand(time(NULL));
printf ("请选择模式\n1:2红1蓝\n2:6红1蓝\n");
scanf ("%d", &T);
system("cls");
if (T == 1) {
for (int i = 1; i <= 3; i++) {
ans[i] = rand() % 10;
}
printf ("你有3次机会\n");
for (int i = 1; i <= 3; i++) {
for (int j = 1; j <= 3; j++) {
scanf ("%d", &table[j]);
}
for (int j = 1; j <= 3; j++) {
if (ans[j] != table[j]) {
f = false;
break;
}
}
if (f) {
printf("恭喜你!!!!!!获得了十万奖金!!!\n");
return 0;
} else {
printf ("不对!\n");
}
}
printf ("正确号码是:\n");
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED);
printf ("%d %d ", ans[1], ans[2]);
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_BLUE);
printf ("%d\n", ans[3]);
} else {
for (int i = 1; i <= 7; i++) {
ans[i] = rand() % 10;
}
printf ("你有7次机会\n");
printf ("%d\n", ans[7]);
for (int i = 1; i <= 7; i++) {
for (int j = 1; j <= 7; j++) {
scanf ("%d", &table[j]);
}
for (int j = 1; j <= 7; j++) {
if (ans[j] != table[j]) {
f = false;
break;
}
}
if (f) {
printf("恭喜你!!!!!!获得了八千万奖金!!!\n");
return 0;
} else {
printf ("不对!\n");
}
}
printf ("正确号码是:\n");
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED);
for (int i = 1; i <= 6; i++) {
printf ("%d ", ans[i]);
}
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_BLUE);
printf ("%d\n", ans[7]);
}
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_BLUE | FOREGROUND_RED | FOREGROUND_GREEN);
return 0;
}
关注!!!