diff --git a/practice_code/idea/Student _Manage _System/main.c b/practice_code/idea/Student _Manage _System/main.c index 95e117f..5debb85 100644 --- a/practice_code/idea/Student _Manage _System/main.c +++ b/practice_code/idea/Student _Manage _System/main.c @@ -11,60 +11,156 @@ //初始化全局变量 bool pick_revision = true;//初始化文件是否修改 bool pick_view_mode = false;//视图模式 -unsigned int Total =0;//初始化学生总数 +unsigned int Total = 0;//初始化学生总数 + +static struct Snake +{ + //0为y,1为x + int head[2]; + int body[2]; + int tail[2]; +}; + +struct Snake snake ; + +static void printf_main ( void )//主页菜单 +{ + HideCursor ( );//隐藏光标 + system ( "cls" );//清屏 + + CursorJump ( 8 , 50 ); + color ( 2 );//设置颜色 + printf ( "欢迎使用学生管理系统" ); + CursorJump ( 9 , 48 ); + color ( 4 );//设置颜色 + printf ( "按下相应按键进入对应模式" ); + + CursorJump ( 10 , 47 ); + for ( int i = 0 ; i < 26 ; ++ i ) + { + color ( 7 );//设置颜色 + printf ( "-" ); + } + + CursorJump ( 11 , 52 ); + color ( 1 );//设置颜色 + printf ( "[Enter]" ); + color ( 7 );//设置颜色 + printf ( " 进入程序\n" ); + CursorJump ( 12 , 52 ); + color ( 1 );//设置颜色 + printf ( "[M]" ); + color ( 7 );//设置颜色 + printf ( "\t 课程管理" ); + + CursorJump ( 13 , 52 ); + color ( 1 );//设置颜色 + printf ( "[ESC]" ); + color ( 7 );//设置颜色 + printf ( " 退出程序\n" ); + + for ( int i = 6 ; i <= 15 ; ++ i ) + { + for ( int j = 45 ; j <= 74 ; ++ j ) + { + if ( i == 6 || i == 15 || j == 45 || j == 74 ) + { + CursorJump ( i , j ); + color ( 7 );//设置颜色 + printf ( "■" ); + } + } + } +} + +static void move_snake(void)//移动小蛇 +{ + Sleep (80); + CursorJump ( snake.tail[0] , snake.tail[1] ); + printf (" "); + snake.tail[0]=snake.body[0]; + snake.tail[1]=snake.body[1]; + snake.body[0]=snake.head[0]; + snake.body[1]=snake.head[1]; + if(snake.head[0]==6&&snake.head[1]<74) + { + snake.head[1]++; + } + else if(snake.head[1]==74&&snake.head[0]<15) + { + snake.head[0]++; + } + else if(snake.head[0]==15&&snake.head[1]>45) + { + snake.head[1]--; + } + else if(snake.head[1]==45&&snake.head[0]>7) + { + snake.head[0]--; + } + else + { + snake.tail[0]=6; + snake.tail[1]=45; + snake.body[0]=6; + snake.body[1]=46; + snake.head[0]=6; + snake.head[1]=47; + printf_main(); + } + color ( 13 );//设置颜色 + CursorJump ( snake.tail[0] , snake.tail[1] ); + printf ("□"); + CursorJump ( snake.body[0] , snake.body[1] ); + printf ("□"); + CursorJump ( snake.head[0] , snake.head[1] ); + printf ("■"); +} + + //主函数 int main ( void ) { //定义变量 - static char start_pick='0';//开始的选择 - srand((unsigned)time(NULL)); - while(1) + static char start_pick = '0';//开始的选择 + snake.head[0]=7; + snake.head[1]=45; + srand ( ( unsigned ) time ( NULL ) ); + while ( 1 ) { - //打印菜单 - HideCursor ();//隐藏光标 - system ( "cls" );//清屏 - printf ( "\n\n\n\n\n\n\n\n" ); - color(2);//设置颜色 - printf ("\t\t\t\t\t\t 欢迎使用学生管理系统\n"); - - printf ("\t\t\t\t\t\t"); - for ( int i = 0 ; i < 28 ; ++ i ) - { - color(rand()%9+1);//设置颜色 - printf ("■"); - } - printf("\n"); - color(1);//设置颜色 - printf ("\t\t\t\t\t\t[Enter]"); - color(7);//设置颜色 - printf (" 进入程序\n"); - color(1);//设置颜色 - printf ( "\t\t\t\t\t\t[ESC]" ); - color(7);//设置颜色 - printf (" 退出程序\n"); - color(4);//设置颜色 - printf ("\t\t\t\t\t\t按下相应按键进入对应模式\n"); + move_snake();//移动小蛇 //获取用户的输入 - if(_kbhit()) + if ( _kbhit ( ) ) { - start_pick=(char)_getch(); + start_pick = ( char ) _getch ( ); } //判断用户输入 - switch(start_pick) + switch ( start_pick ) { case ENTER: { - start_pick='0'; - system_start();//管理系统主页 + start_pick = '0'; + system_start ( );//管理系统主页 + snake.head[0]=7; + snake.head[1]=45; break; } + case 'm': + case 'M': + { + start_pick = '0'; + system_start ( );//管理系统主页 + snake.head[0]=7; + snake.head[1]=45; + break; + } + case ESC: { return 0; } } - Sleep(2); } return 0; } \ No newline at end of file diff --git a/practice_code/idea/Student _Manage _System/page_newly_built.c b/practice_code/idea/Student _Manage _System/page_newly_built.c index fb9a4bf..fed8c2b 100644 --- a/practice_code/idea/Student _Manage _System/page_newly_built.c +++ b/practice_code/idea/Student _Manage _System/page_newly_built.c @@ -9,5 +9,5 @@ void newly_built(void) { - + // } \ No newline at end of file