#include<bits/stdc++.h>
#include<cstring>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <conio.h>
#include <cmath>
#include <windows.h>
using namespace std;
HANDLE hout=GetStdHandle(STD_OUTPUT_HANDLE);
COORD coord;
void locate(int x,int y)
{
coord.X=y;
coord.Y=x;
SetConsoleCursorPosition(hout,coord);
};
void hide()
{
CONSOLE_CURSOR_INFO cursor_info={1,0};
SetConsoleCursorInfo(hout, &cursor_info);
}
double random(double start, double end)
{
return start+(end-start)*rand()/(RAND_MAX + 1.0);
}
int m,n;
struct node
{
int x,y;
}snake[1000];
int snake_length,dir;
node food;
int direct[4][2]={
{-1,0},{1,0},{0,-1},{0,1}};
void print_wall()
{
cout << " ";
for (int i=1;i<=n;i++)
cout << "-";
cout << endl;
for (int j=0;j<=m-1;j++)
{
cout << "|";
for (int i=1;i<=n;i++) cout << " ";
cout << "|" << endl;
}
cout << " ";
for (int i=1;i<=n;i++)
cout << "-";
}
void print_snake()
{
locate(snake[0].x,snake[0].y);
cout << "@";
for (int i=1;i<=snake_length-1;i++)
{
locate(snake[i].x,snake[i].y);
cout << "*";
}
}
bool is_correct()
{
if (snake[0].x==0 || snake[0].y==0 || snake[0].x==m+1 || snake[0].y==n+1) return false;
for (int i=1;i<=snake_length-1;i++)
{
if (snake[0].x==snake[i].x && snake[0].y==snake[i].y) return false;
}
return true;
}
boo
C++小程序系统
最新推荐文章于 2023-07-26 09:00:00 发布