#include <stdio.h>
int main(int argc, const char * argv[]) {
char direction;
int flag = 1;
printf("请控制小人移动:w.上 s.下 a.左 d.右 q.退出\n");
while (flag) {
scanf("%c",&direction);
switch (direction) {
case 'w':
case 'W':
printf("上\n");
break;
case 's':
case 'S':
printf("下\n");
break;
case 'a':
case 'A':
printf("左\n");
break;
case 'd':
case 'D':
printf("右\n");
break;
case 'q':
case 'Q':
printf("正在退出...\n");
printf("已经退出。\n");
printf("see you...\n");
flag = 0;
break;
default:
break;
}
}
return 0;
}
|
|