[ create a new paste ] login | about

Link: http://codepad.org/gyEKMcrm    [ raw code | output | fork ]

C, pasted on Sep 26:
#include <stdio.h>
#include <string.h>

#define MAX_ARRAY_SIZE 5

int main()
{
    int arr[MAX_ARRAY_SIZE];
    int op_arra[10][MAX_ARRAY_SIZE], *temp;
    int i, j, k = 0, len = 0;

    printf("Enter the pair of inputs :");
    for (i = 0; i < MAX_ARRAY_SIZE; i++)
        scanf("%d", &arr[i]);

    temp = arr;
    len = MAX_ARRAY_SIZE;

    memset(op_arra, 0, sizeof(op_arra));

    while (temp) {
        for (i = 0, j = 0; i < len - 1; i++) {
            op_arra[k][j++] = temp[i] + temp[i + 1];
        }
        if (len == 1)
            break;

        temp = op_arra[k++];
        len--;
    }

    while(k) {
        for (i = 0, j = k - 1; op_arra[j][i]; i++)
            printf("%d ", op_arra[j][i]);

        printf("\n");
        k--;
    }

    for (i = 0; i < MAX_ARRAY_SIZE; i++)
        printf("%d ", arr[i]);

    printf("\n");

    return 0;
}


Output:
1
2
3
4
5
Enter the pair of inputs :-759711088 
-726110170 -33600918 
-431870068 -294240102 260639184 
-146018988 -285851080 -8389022 269028206 
-3070752 -142948236 -142902844 134513822 134514384 


Create a new paste based on this one


Comments: