|
- #include <stdio.h>
- #include <stdlib.h>
- #include <windows.h>
- #define START 77 /* 起始打印的空格数,控制台默认宽度是80,这个值不应该大于77,否则图形会错版 */
- #define END 1 /* 结束时的位置,不可以小于1 */
- int main()
- {
- int i, counter;
- i = START;
- while(i > END)
- {
- system("cls");
-
- /* 首先打印空格,让小人在屏幕右边出现 */
- counter = 0;
- while(counter < i)
- {
- printf(" ");
- counter = counter + 1;
- }
- /* 打印头部 */
- printf("O\n");
-
- /* 和之前类似,打印躯干和腿部 */
- counter = 0;
- while(counter < i - 1)
- {
- printf(" ");
- counter = counter + 1;
- }
- printf("<H>\n");
- counter = 0;
- while(counter < i - 1)
- {
- printf(" ");
- counter = counter + 1;
- }
- printf("I I\n");
-
- /* 控制小人跑动的速率 */
- Sleep(200);
-
- /* 下次循环打印的空格数 -1 */
- --i;
- }
- system("pause");
- return 0;
- }
复制代码 |
|