URI Online Judge | 1133
Resto da Divisão
Adaptado por Neilor Tonin, URI
Brasil
Timelimit: 1
Escreva um programa que leia 2 valores X e Y e que imprima todos os valores entre eles cujo resto da divisão dele por 5 for igual a 2 ou igual a 3.
Entrada
O arquivo de entrada contém 2 valores positivos inteiros quaisquer, não necessariamente em ordem crescente.
Saída
Imprima todos os valores conforme exemplo abaixo, sempre em ordem crescente.
URI Online Judge | 1133
Rest of a Division
Adapted by Neilor Tonin, URI
Brazil
Timelimit: 1
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.
#include<stdio.h>
int main(){
int X, Y, cont;
scanf("%d%d", &X,&Y);
if (X > Y) {
for (cont = Y+1 ; cont < X; cont++) {
if (cont % 5 == 2 || cont % 5 == 3) {
printf("%d\n", cont);}
}
}else if(X < Y){
for (cont = X+1 ; cont < Y; cont++) {
if (cont % 5 == 2 || cont % 5 == 3) {
printf("%d\n", cont);
}
}
}
}