Algorithm


Problem Name: beecrowd | 1097
Problem Link: https://www.beecrowd.com.br/judge/en/problems/view/1097

Sequence IJ 3

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=9
I=3 J=8
I=3 J=7
...
I=9 J=15
I=9 J=14
I=9 J=13

 

Code Examples

#1 Code Example with C Programming

Code - C Programming


#include <stdio.h>

int main()
{
    int I,J;
    for(I=1;I < =9;I=I+2)
    {
        for(J=6+I;J>3+I;J--)
            printf ("I=%d J=%d\n",I,J);
    }
    return 0;
}
Copy The Code & Try With Live Editor

Output

x
+
cmd
I=1 J=7 I=1 J=6 I=1 J=5 I=3 J=9 I=3 J=8 I=3 J=7 ... I=9 J=15 I=9 J=14 I=9 J=13

#2 Code Example with C++ Programming

Code - C++ Programming


#include <iostream>

using namespace std;

int main(){
    int j = 7;
    for(int i = 1; i  < = 9; i++){
            cout << "I=" << i << " " << "J=" << j << "\n";
            cout << "I=" << i << " " << "J=" << j-1 << "\n";
            cout << "I=" << i << " " << "J=" << j-2 << "\n";
            i++;
            j+=2;
    }
    return 0;
}
Copy The Code & Try With Live Editor

Output

x
+
cmd
I=1 J=7 I=1 J=6 I=1 J=5 I=3 J=9 I=3 J=8 I=3 J=7 ... I=9 J=15 I=9 J=14 I=9 J=13

#3 Code Example with Python Programming

Code - Python Programming


for i in range(1,10,2):
    for j in range(6+i,3+i,-1):
        print(f"I={i} J={j}")
Copy The Code & Try With Live Editor

Output

x
+
cmd
I=1 J=7 I=1 J=6 I=1 J=5 I=3 J=9 I=3 J=8 I=3 J=7 ... I=9 J=15 I=9 J=14 I=9 J=13
Advertisements

Demonstration


Previous
#1096 Beecrowd Online Judge Solution 1096 Sequence IJ 2 - Solution in C, C++, Java, Python and C#
Next
#1098 Beecrowd Online Judge Solution 1098 Sequence IJ 4 - Solution in C, C++, Java, Python and C#