滚动数组的简单应用

题目:http://acm.swust.edu.cn/oj/problem/324/

View Code
//1.动态范围

//2.动态次数

//3.动态规律

//4.动态边界

#include <stdio.h>

#include<string.h>

int main()

{

    int Live, Stand, Step;

    int f[101][2];

    while(scanf("%d%d%d", &Live, &Step, &Stand)!=EOF){

        memset(f, 0, sizeof(f));

        f[Stand][0] = 1;

        int Roll = 1;

        for(int i=0; i<Step; i++){

            for(int j=1; j<100; j++){

                f[j][Roll] = f[j-1][1-Roll]+f[j+1][1-Roll];

            }

            f[100][Roll] = f[99][1-Roll];

            Roll = 1-Roll;

        }

        printf("%d\n", f[Live][1-Roll]);

    }

}

你可能感兴趣的:(数组)