求大神看看这两个小程序写得怎样
#include "stdio.h"#include "conio.h"
int map[15][15]={
1,1,0,1,0,0,0,0,0,0,0,0,0,0,1,
1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,};
int x=10,y=10,j,k;
int draw(int a,int b)
{
int c=0;
clrscr();
for(j=0;j<15;j++)
for(k=0;k<15;k++)
{
if(map[j][k]==1)
{
if(a==j&&k==b)map[j][k]=0;
gotoxy(j,k);
printf("%c",'b');
c+=map[j][k];
}
}
return c;
}
void xy(int x,int y)
{
gotoxy(x,y);
printf("%c",'a');
}
void main()
{
int a,l,v,c;
while((a=getch())!='\n')
{
switch(a)
{
case 'w':y--;break;
case 's':y++;break;
case 'a':x--;break;
case 'd':x++;break;
default :
printf("您按错了");
}
v=x-1;
c=y-1;
l=draw(v,c);
xy(v,c);
if(l==0)break;
}
printf("您胜利了");
#include "stdio.h"
#include "string.h"
#define PI 16
#define A 10
#define B 11
#define C 12
#define D 13
#define E 14
#define F 15
int z;
int abc(int a[10],int i)
{
int c,d,w,v,t=0;
for(v=0;v<=i;v++)
{
if(1==v)
{
d=a[v]*PI;
}
if(v>1)
{
w=PI*16; a[v]*=w; t+=a[v];
}
}
return(d+t+a[0]);
}
void main()
{
int a,b,c;
int e[10];
scanf("%d",&a);
z=a;
for(b=0;b<10;b++)
{
e[b]=a%PI;
a=a/PI;
if(a<PI){e[++b]=a;break;}
}
c=abc(e,b);
for(;b>=0;b--)
{
switch(e[b])
{
case 0:e[b]='0';break;
case 1:e[b]='1';break;
case 2:e[b]='2';break;
case 3:e[b]='3';break;
case 4:e[b]='4';break;
case 5:e[b]='5';break;
case 6:e[b]='6';break;
case 7:e[b]='7';break;
case 8:e[b]='8';break;
case 9:e[b]='9';break;
case 10:e[b]='A';break;
case 11:e[b]='B';break;
case 12:e[b]='C';break;
case 13:e[b]='D';break;
case 14:e[b]='E';break;
case 15:e[b]='F';break;
default : break;
}
printf("%c",e[b]);
}
printf("\n校验结果%d",c);
if(z==c)printf("结果是正确的!!!");
else printf("结果不是正确的??");
}
第一个是参照百度文库写的
第二个是上班时候没事写的求大神精简一下