Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
816 B
2
Indexable
Never
#include <stdio.h>
int iscon(long long num)
{
    long long prevdig = num % 10;
    num /= 10;
     while (num > 0)
    {
        long long curdig = num % 10;
        if (curdig + 1 != prevdig)
            return 0;
        num /= 10;
        prevdig = curdig;
    }

    return 1;
}

int main()
{
    long long l, r;
    scanf("%lld %lld", &l, &r);

    long long consecutiveNumbers[1000];
    int count = 0;
    for (long long num = l; num <= r; num++)
    {
        if (iscon(num))
        {
            consecutiveNumbers[count] = num;
            count++;
        }
    }
    printf("[");
    for (int i = 0; i < count; i++)
    {
        printf("%lld", consecutiveNumbers[i]);
        if (i < count - 1)
            printf(",");
    }
    printf("]");
    return 0;
}