Untitled

mail@pastecode.io avatar
unknown
c_cpp
a year ago
1.0 kB
3
Indexable
#include <stdio.h>

int sum_num(int num){
    int sum = 0;
    while (num != 0){
        sum += num % 10;
        num /= 10;
    }
    return sum;
}



int main() {
    int a, b, c, d, t, sum, root1, root2, root3, root4, a4, a3, a2, a1, a0, c1, c2, c3, c4, c5;
    printf("");
    scanf("%d", &t);
    printf("");
    scanf("%d %d %d %d", &root1, &root2, &root3, &root4);
    a = t / 1000;
    b = (t / 100) % 10;
    c = (t / 10) % 10;
    d = t % 10;
    sum = a + b + c + d;
    a4 = 1;
    a3 = -(root1 + root2 + root3 + root4);
    a2 = root1 * root2 + root1 * root3 + root1 * root4 + root2 * root3 + root2 * root4 + root3 * root4;
    a1 = -(root1 * root2 * root3 + root2 * root3 * root4 + root1 * root3 * root4 + root1 * root2 * root4);
    a0 = root1 * root2 * root3 * root4;

    printf("%i\n\n", sum);

    for (int i = 0; i < 5; i++){
        printf("%5d", 4 - i);
    }
    printf("\n");
    printf("%5d", a4);
    printf("%5d", a3);
    printf("%5d", a2);
    printf("%5d", a1);
    printf("%5d", a0);
    printf("\n");
}