All pastes #989715 Raw Edit

poullin.c

public text v1 · immutable
#989715 ·published 2008-04-19 17:02 UTC
rendered paste body
#include <stdio.h>
#include <string.h>

int d_n(int n)
        {
                int res = 0;
                while ((n / 10) > 0) {
                res += (n % 10);
                n = (n / 10);
                }
                res += n;
                return res;
        }
int check_self(int z, int v)
        {
                int res = 1, i;
                for (i = (z - 81); i <= z; i++)
                        if ( d_n(v) == i)
                                res = 0;
                return res;
        }
void swap (int a, int b)
        {
        int c;
        c = a; a = b; b = c;
        }
int main (int argc, char ** argv)
{
        int x=0, a, i, j;
        i = atoi(argv[1]);
        j = atoi(argv[2]);
        if (i > j) swap(i,j);
        for (a = i; a <= j;a++) if (check_self(i,j) == 1) x++;
        printf("%d", x);
}