URI Online Judge | 1096
Sequence IJ 2
Adapted by Neilor Tonin, URI Brazil
Timelimit: 1
Make a program that prints the sequence like the following exemple.
Input
This problem doesn't have input.
Output
Print the sequence like the example below.
Input Sample | Output Sample |
I=1 J=7 I=1 J=6 I=1 J=5 I=3 J=7 I=3 J=6 I=3 J=5 ... I=9 J=7 I=9 J=6 I=9 J=5 |
URI Online Judge Solution 1096 || Sequence IJ 2 in Java
import
java.io.IOException;
public
class
Main {
public
static
void
main(String[] args)
throws
IOException {
for
(
int
i =
1
; i <=
9
; i +=
2
) {
for
(
int
I = i,J =
7
; (J >=
5
); J-=
1
) {
System.out.print(
"I="
+I+
" J="
+J+
"\n"
);
}
}
}
}
URI Online Judge Solution 1096 || Sequence IJ 2 in C
#include<stdio.h>
int main(){
int i, I, J;
for (int i = 1; i <= 9; i += 2) {
for (int I = i,J = 7; (J >= 5); J-=1) {
printf("I=%d J=%d\n", I, J);
}
}
return 0;
}
Question link URI
No comments:
Write commentsTo know more about the problem, give us your valuable commment. We'll try to help you. Thanks