Friday, December 11, 2015

蓝桥杯程序设计大赛真题及解析 >> 振兴中华

```int main( )
{
char c_i = 0;
char c_j = 0;
char c_arr[4][5] = {0};

clock_t start, finish;
start = clock();

for(c_i=0; c_i<4; c_i++)
c_arr[c_i][0] = 1;

for(c_j=0; c_j<5; c_j++)
c_arr[0][c_j] = 1;

for(c_i=1; c_i<4; c_i++)
for(c_j=1; c_j<5; c_j++)
c_arr[c_i][c_j] = c_arr[c_i-1][c_j] + c_arr[c_i][c_j-1] ;
printf("总共有%d种路线\n", c_arr[3][4]);

finish = clock();
printf( "\n\n\n程序运行时间：%.3f ms\n", (double)(finish - start));

return 0;
}```
http://www.mofriend.net/node/449
int s=0;
void walk(int x,int y)
{
if(x>3 || y>4)
return;
if(x==3 && y==4)
{
s++;
return;
}
walk(x+1,y);
walk(x,y+1);
}
int main()
{
walk(0,0);
printf("%d",s);
return 0;
}
```void find(int i,int j,int cur)
{
if(t[i][j]==8){
count++;
return;
}
if(i>0&&t[i-1][j] == cur+1)
find(i-1, j,cur+1);
if(i<3&&t[i+1][j] == cur+1) find(i+1, j, cur+1); if(j>0&&t[i][j-1] == cur+1)
find(i, j-1, cur+1);
if(j<4&&t[i][j+1] == cur+1)
find(i, j+1, cur+1);

return;
}

int main()
{
find(0, 0, 1);
printf("%d\n",count);
return 0;
}```