关于方向键控制笑脸移动问题求解
自己瞎摸索的,程序有些混乱,烦劳高手费心解答啊,怎么实现?这个不对的#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<conio.h>
int main()
{
char a[10][10];
int i,j,m = 5,n = 5,k = 1;
char direction;
for(;direction != '\n';)
{
system("cls");
for(i = 0;i < 10;i++)
for(j = 0;j < 10;j++)
a[i][j] = ' ';
a[m][n] = 1;
for(i = 0;i < 10; i++)
{
for(j = 0;j < 10; j++)
printf("%-2c",a[i][j]);
printf("\n");
}
direction = getch();
switch(direction)
{
case 'w':a[m--][n] = 1;
case 's':a[m++][n] = 1;
case 'a':a[m][n--] = 1;
case 'd':a[m][n++] = 1;
}
for(i = 0;i < 10; i++)
{
for(j = 0;j < 10; j++)
printf("%-2c",a[i][j]);
printf("\n");
}
m = m;n = n;
}
}