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 integer numbers X and Y without any order.
Output
Print all numbers according to above description, always in ascending order.
Input Sample | Output Sample |
10 18 | 12 13 17 |
URI Online Judge Solution 1133 || Rest of a Division in C Language
#include<stdio.h>
int main(){
int X, Y, i;
scanf("%d%d", &X,&Y);
if (X > Y) {
for (i = Y+1 ; i < X; i++) {
if (i % 5 == 2 || i % 5 == 3) {
printf("%d\n", i);
}
}
}else if(X < Y){
for (i = X+1 ; i < Y; i++) {
if (i % 5 == 2 || i % 5 == 3) {
printf("%d\n", i);
}
}
}
}
URI Online Judge Solution 1133 || Rest of a Division in Java Language
import
java.io.IOException;
import
java.util.Scanner;
public
class
Main {
public
static
void
main(String[] args)
throws
IOException {
int
X, Y;
Scanner input =
new
Scanner(System.in);
X = input.nextInt();
Y = input.nextInt();
if
(X > Y) {
for
(
int
i = Y+
1
; i < X; i++) {
if
(i %
5
==
2
|| i %
5
==
3
) {
System.out.print(i+
"\n"
);
}
}
}
else
if
(Y > X){
for
(
int
i = X+
1
; i < Y; i++) {
if
(i %
5
==
2
|| i %
5
==
3
) {
System.out.print(i+
"\n"
);
}
}
}
}
}
URI Main Question link
i = y+1 ta keno dilam bujhlam na bepar ta ami tu deini but amar output same ashse but 5% error dekhacche
ReplyDeleteami o bujte parchi na
Deleteamr o 5% "WA" dicche
ei ta amr code
https://onlinegdb.com/cLv-W2IYg