佩服啊!好厉害!动态规划
Maybe
#include<stdio.h> void f(int m,int n,int k) { int a[102] = {0}, b[102] = {0}, *pa = a, *pb = b, *pt, i, j,l; for(a[m] = 1, i = 1; i <= n; i++, pt = pa, pa = pb, pb = pt) for(j = (m-i>=1?m-i:1),l=(m+i<=100?m+i:100); j <= l; j++) pb[j] = pa[j - 1] + pa[j + 1]; printf("%d\n",pa[k]); } void main() { int m, n, k; scanf("%d%d%d", &m, &n, &k); f(m, n, k); }的确还可以优化,for里三目判断效率低了,多谢杨大哥指点