c语言扫雷游戏代码主函数
时间: 2024-01-12 10:21:49 浏览: 89
根据提供的引用内容,以下是一个C语言扫雷游戏代码的主函数示例:
```c
#include <stdio.h>
#include <stdlib.h>
#include "game.h"
int main() {
int choice;
int rows, cols, mines;
printf("Welcome to Minesweeper!\n");
printf("1. New Game\n");
printf("2. Exit\n");
printf("Enter your choice: ");
scanf("%d", &choice);
switch (choice) {
case 1:
printf("Enter the number of rows: ");
scanf("%d", &rows);
printf("Enter the number of columns: ");
scanf("%d", &cols);
printf("Enter the number of mines: ");
scanf("%d", &mines);
game(rows, cols, mines);
break;
case 2:
printf("Exiting the game...\n");
exit(0);
default:
printf("Invalid choice. Exiting the game...\n");
exit(0);
}
return 0;
}
```
阅读全文