URI Online Judge Solution 1133 Rest of a Division using C Programming.
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 Sample | Output Sample |
10
18 |
12
13 17 |
Solution using C :
#include <stdio.h>
int main() {
int x,y,i;
scanf("%d%d",&x,&y);
if(x>y)
{
int t = x;
x = y;
y = t;
}
for(i=x+1; i<y; i++)
{
int r = i%5;
if(r == 2 || r == 3)
printf("%d\n",i);
}
return 0;
}
Comments
Post a Comment