别踩白块儿c语言代码
时间: 2023-12-11 17:32:36 浏览: 53
以下是一个简单的别踩白块儿C语言代码的实现:
```c
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <windows.h>
#define ROW 10
#define COL 10
int main()
{
int i, j, k, score = 0;
char ch;
int a[ROW][COL] = {0};
int speed = 300;
while (1) {
system("cls");
for (i = ROW - 1; i >= 0; i--) {
for (j = 0; j < COL; j++) {
if (a[i][j] == 1) {
printf("■");
} else {
printf(" ");
}
}
printf("\n");
}
if (kbhit()) {
ch = getch();
if (ch == 'a') {
for (i = ROW - 1; i >= 0; i--) {
for (j = 0; j < COL - 1; j++) {
a[i][j] = a[i][j + 1];
}
a[i][COL - 1] = 0;
}
a[ROW - 1][rand() % COL] = 1;
}
} else {
for (i = ROW - 1; i >= 1; i--) {
for (j = 0; j < COL; j++) {
a[i][j] = a[i - 1][j];
}
}
for (j = 0; j < COL; j++) {
a[0][j] = 0;
}
a[0][rand() % COL] = 1;
}
for (k = 0; k < score / 10; k++) {
speed -= 10;
}
Sleep(speed);
for (j = 0; j < COL; j++) {
if (a[ROW - 1][j] == 1) {
printf("Game Over! Your score is %d.\n", score);
system("pause");
return 0;
}
}
score++;
}
return 0;
}
```
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![-](https://img-home.csdnimg.cn/images/20210720083327.png)
![-](https://img-home.csdnimg.cn/images/20210720083327.png)
![-](https://img-home.csdnimg.cn/images/20210720083327.png)
![-](https://img-home.csdnimg.cn/images/20210720083327.png)
![-](https://img-home.csdnimg.cn/images/20210720083327.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)