UVA Solution 326 - Extrapolation Using a Difference Table - Solution in C, C++ | Volume 3 - Online Judge Solution

Latest

It is a free Online judges problems solution list. Here you can find UVA online Judge Solution, URI Online Judge Solution, Code Marshal Online Judge Solution, Spoz Online Judge Problems Solution

Friday, May 5, 2017

UVA Solution 326 - Extrapolation Using a Difference Table - Solution in C, C++ | Volume 3

UVA Solution 326 - Extrapolation Using a Difference Table - Solution in C, C++ | Volume 3


UVA Online Judge Solution 326 - Extrapolation Using a Difference Table | Volume 3
UVA Problem Link - 

Problem Name: 326 - Extrapolation Using a Difference Table
Problem Number : UVA - 326 - Extrapolation Using a Difference Table
Online Judge : UVA Online Judge Solution
Volume: 3
Solution Language : C, C plus plus

UVA Solution 326 - Extrapolation Using a Difference Table - Solution in C, C++ | Volume 3

UVA Solution 326 - Extrapolation Using a Difference Table Code in C, CPP:


#include <stdio.h>

int main() {
    int n, k, i, j;
    int a[150];
    while(scanf("%d", &n) == 1 && n) {
        for(i = 0; i < n; i++)
            scanf("%d", &a[i]);
        scanf("%d", &k);
        for(j = n-1; j >= 0; j--)
            for(i = 0; i < j; i++)
                a[i] = a[i+1] - a[i];
        for(j = 0; j < k; j++)
            for(i = 1; i < n; i++)
                a[i] += a[i-1];
        printf("Term %d of the sequence is %d\n", n+k, a[n-1]);
    }
    return 0;
}

No comments:

Post a Comment