#include
#include
#include
Copyright By PowCoder代写 加微信 powcoder
#include
#include
#include
#include
#include
#define ROW 10
#define COLUMN 50
struct Node{
int x , y;
Node( int _x , int _y ) : x( _x ) , y( _y ) {};
Node(){} ;
char map[ROW+10][COLUMN] ;
// Determine a keyboard is hit or not. If yes, return 1. If not, return 0.
int kbhit(void){
struct termios oldt, newt;
tcgetattr(STDIN_FILENO, &oldt);
newt = oldt;
newt.c_lflag &= ~(ICANON | ECHO);
tcsetattr(STDIN_FILENO, TCSANOW, &newt);
oldf = fcntl(STDIN_FILENO, F_GETFL, 0);
fcntl(STDIN_FILENO, F_SETFL, oldf | O_NONBLOCK);
ch = getchar();
tcsetattr(STDIN_FILENO, TCSANOW, &oldt);
fcntl(STDIN_FILENO, F_SETFL, oldf);
if(ch != EOF)
ungetc(ch, stdin);
void *logs_move( void *t ){
/* Move the logs */
/* Check keyboard hits, to change frog’s position or quit the game. */
/* Check game’s status */
/* Print the map on the screen */
int main( int argc, char *argv[] ){
// Initialize the river map and frog’s starting position
memset( map , 0, sizeof( map ) ) ;
int i , j ;
for( i = 1; i < ROW; ++i ){
for( j = 0; j < COLUMN - 1; ++j )
map[i][j] = ' ' ;
for( j = 0; j < COLUMN - 1; ++j )
map[ROW][j] = map[0][j] = '|' ;
for( j = 0; j < COLUMN - 1; ++j )
map[0][j] = map[0][j] = '|' ;
frog = Node( ROW, (COLUMN-1) / 2 ) ;
map[frog.x][frog.y] = '0' ;
//Print the map into screen
for( i = 0; i <= ROW; ++i)
puts( map[i] );
/* Create pthreads for wood move and frog control. */
/* Display the output for user: win, lose or quit. */
程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com