一个弹弹球

 1 #include<stdio.h>
 2 #include<stdlib.h>
 3 #include<windows.h>
 4 int main()
 5 {
 6     int x=1,y=1;
 7     int v_x=1,v_y=1;
 8     int i=0,j=0;
 9     while(1)
10     {
11         CONSOLE_CURSOR_INFO cursor_info = { 1,0};//第二个值0表示隐藏光标
12         SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE), &cursor_info); 
13         system("cls"); 
14         if(x>=20||x<1)
15         {
16             v_x*=-1;
17             printf("a");
18         }
19         if(y>=25||y<1)
20         {
21             v_y*=-1;
22             printf("a");
23         }
24 
25         for(i=0;i<x&&x<20;i++)
26         {
27             printf("
");
28         }
29         for(j=0;j<y&&y<25;j++){
30             printf("  ");
31         }
32         x+=v_x;
33         y+=v_y;
34         printf("o
");
35         Sleep(0.01);
36 
37     }
38 
39     return 0;
40 }
天涯犹在,不诉薄凉。
原文地址:https://www.cnblogs.com/Knight02/p/13967203.html