1133 Rest of a Division

SemiColon
By -
0
URI Online Judge | 1133

Rest of a Division

Write a program that reads two integer numbers X and Y. Print all numbers between X and Y which dividing it by 5 the rest is equal to 2 or equal to 3.

Input

The input file contains 2 any positive integers, not necessarily in ascending order.

Output

Print all numbers according to above description, always in ascending order.
Input SampleOutput Sample
10
18
12
13
17


Solution:



#include <stdio.h>
int main()
{
    int a,b,i;
    scanf("%d %d", &a, &b);
    if(a<b)
    {
        for(i=a+1; i<b; i++)
        {
            if(i%5==2 || i%5==3)
                printf("%d\n",i);
        }
    }
    else if(a>b)
    {
        for(i=b+1; i<a; i++)
        {
            if(i%5==2 || i%5==3)
                printf("%d\n",i);
        }
    }
    return 0;
}

Tags:

Post a Comment

0Comments

Post a Comment (0)