闲来无事,看看这个算术游戏吧。
正好考考你的算术能力。
有点恶搞。
#include <stdio.h>
#include <windows.h>
using namespace std;
int choice;
void exit();
void level_1();
void level_2();
void level_3();
void level_4();
void level_5();
int main() {
system("cls");
MessageBox(NULL, "恭喜你进入了游戏!", "welcome", MB_OK);
MessageBox(NULL, "现在开始游戏", "start", MB_OK);
printf("算数游戏\n");
printf("1.start\n");
printf("2.exit\n");
scanf("%d", &choice);
switch(choice) {
case 1:
level_1();
break;
case 2:
exit();
break;
default:
MessageBox(NULL, "退出游戏!", "stop", MB_OK);
}
return 0;
}
void exit() {
system("cls");
MessageBox(NULL, "确定退出?(1/0)", "exit", MB_OK);
scanf("%d", &choice);
switch(choice) {
case 1:
MessageBox(NULL, "好的,已退出", "exit", MB_OK);
break;
case 2:
main();
break;
default:
main();
}
}
void level_1() {
system("cls");
MessageBox(NULL, "现在开始第一关", "level_1", MB_OK);
MessageBox(NULL, "1+1=?", "level_1", MB_OK);
scanf("%d", &choice);
while (choice != 2) {
MessageBox(NULL, "不对!", "level_1", MB_OK);
scanf("%d", &choice);
}
MessageBox(NULL, "答对了!", "level_1", MB_OK);
level_2();
}
void level_2() {
system("cls");
MessageBox(NULL, "现在开始第二关", "level_2", MB_OK);
MessageBox(NULL, "34+45=?", "level_2", MB_OK);
scanf("%d", &choice);
while (choice != 89) {
MessageBox(NULL, "不对!", "level_2", MB_OK);
scanf("%d", &choice);
}
MessageBox(NULL, "答对了!", "level_2", MB_OK);
level_3();
}
void level_3() {
system("cls");
MessageBox(NULL, "现在开始第三关", "level_3", MB_OK);
MessageBox(NULL, "3*9=?", "level_3", MB_OK);
scanf("%d", &choice);
while (choice != 27) {
MessageBox(NULL, "不对!", "level_3", MB_OK);
scanf("%d", &choice);
}
MessageBox(NULL, "答对了!", "level_3", MB_OK);
level_4();
}
void level_4() {
system("cls");
MessageBox(NULL, "现在开始第四关", "level_4", MB_OK);
MessageBox(NULL, "11*15=?", "level_4", MB_OK);
scanf("%d", &choice);
while (choice != 165) {
MessageBox(NULL, "不对!", "level_4", MB_OK);
scanf("%d", &choice);
}
MessageBox(NULL, "答对了!", "level_4", MB_OK);
level_5();
}
void level_5() {
system("cls");
MessageBox(NULL, "现在开始第五关", "level_5", MB_OK);
MessageBox(NULL, "3.5*2=?", "level_5", MB_OK);
scanf("%d", &choice);
while (choice != 7) {
MessageBox(NULL, "不对!", "level_5", MB_OK);
scanf("%d", &choice);
}
MessageBox(NULL, "答对了!", "level_5", MB_OK);
main();
}
标签:MessageBox,OK,游戏,level,算术,MB,choice,NULL,考考你
From: https://blog.csdn.net/NOIP1ding_c/article/details/144619505