Zig Zag structured programming - C : I need a code in which I enter integeres all the time untill I enter something !integer. The code needs to print me the integers who meet the following condition:

    integer "abcde": "a > b, b < c, c > d, d < e" or "a < b, b > c, c < d, d > e"
    example: 343, 4624, 6231209

I have a code written by myself and works for most of the integers but somehow it doesnt work for some

    #include <stdio.h>
    int main()
    {
    int a;
    while(scanf("%d", &a))
    {

        int a1 = a;
        int cifra = 0, cifra1 = 0, cifra2 = 0;
        while(a1 > 0){ 
            cifra = a1 % 10;
            cifra1 = (a1 / 10) % 10;
            cifra2 = (a1 / 100) % 10;
            a1 = a1 / 10;

            if(cifra == cifra1 || cifra1 == cifra2)
            {
            	break;
            }

        if((cifra < cifra1 && cifra1 > cifra2) || (cifra > cifra1 && cifra1 < cifra2))
        {

           printf("%d\n", a);
           break;

        }
        else
        {
            break;
        }
        }
    }
    return 0;
    }






