Monday, June 9, 2014

UVa Solution 900 - Brick Wall Patterns

#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
long long a[105], i;

void fib()
{
    a[0]=1;
    a[1]=1;
    for(i=2; i<51; i++)
    {
        a[i]= a[i-1]+a[i-2];
    }
    return;
}

int main()
{
    fib();
    long long n;
    while(scanf("%lld", &n)==1)
    {
        if(n==0)
        {
            break;
        }
        printf("%lld\n", a[n]);
    }
    return 0;
}

No comments:

Post a Comment

Compare equality of two string in C

#include <stdio.h> #include<string.h> int main() {     char* country = "Bangladesh";     char* country2;     ...