Algorithm


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

Sequence IJ 4

Adapted by Neilor Tonin, URI Brazil

Timelimit: 1

Make a program that prints the sequence like the following example.

Input

This problem doesn't have input.

Output

Print the sequence like the example below.

Input Sample Output Sample
 

I=0 J=1
I=0 J=2
I=0 J=3
I=0.2 J=1.2
I=0.2 J=2.2
I=0.2 J=3.2
.....
I=2 J=?
I=2 J=?
I=2 J=?

 

Code Examples

#1 Code Example with C Programming

Code - C Programming


#include <stdio.h>

int main(){
    float i = 0;
    float j = 1;
    
    while(i  < = 2.2){
            if((i>0 && i<1>|| (i>1 && i<2) || (i>2.1 && i<=2.2) )
			{
			    printf("I=%0.1f J=%0.1f\n",i,j+i);
                            printf("I=%0.1f J=%0.1f\n",i,j+1+i);
                            printf("I=%0.1f J=%0.1f\n",i,j+2+i);
			}
			else
			{
			    printf("I=%d J=%d\n",(int)i,(int)j+(int)i);
                            printf("I=%d J=%d\n",(int)i,(int)j+1+(int)i);
                            printf("I=%d J=%d\n",(int)i,(int)j+2+(int)i);
			}
            
            i+= 0.2;
    }
    return 0;
}
Copy The Code & Try With Live Editor

Output

x
+
cmd
I=0 J=1 I=0 J=2 I=0 J=3 I=0.2 J=1.2 I=0.2 J=2.2 I=0.2 J=3.2 ..... I=2 J=? I=2 J=? I=2 J=?

#2 Code Example with C++ Programming

Code - C++ Programming


#include <iostream>

using namespace std;

int main(){
    float i = 0;
    float j = 1;
    while(i  < = 2.1){
            cout << "I=" << i << " " << "J=" << j+i << "\n";
            cout << "I=" << i << " " << "J=" << j+1+i << "\n";
            cout << "I=" << i << " " << "J=" << j+2+i << "\n";
            i+= 0.2;
    }
    return 0;
}
Copy The Code & Try With Live Editor

Output

x
+
cmd
I=0 J=1 I=0 J=2 I=0 J=3 I=0.2 J=1.2 I=0.2 J=2.2 I=0.2 J=3.2 ..... I=2 J=? I=2 J=? I=2 J=?

#3 Code Example with Python Programming

Code - Python Programming


i = 0
j = 1
value = 0
temp = 0
temp2 = 0
while (i <= 2):
    if (temp2 == 0):
        print("I=%.0f J=%.0f" % (i, j))
    else:
        print("I=%.1f J=%.1f" % (i, j))

    temp += 1
    if (temp == 3):
        i += 0.2
        value += 0.2
        j = value
        temp = 0
        temp2 += 1

    if(temp2 == 5):
        temp2 = 0
    j += 1
Copy The Code & Try With Live Editor

Output

x
+
cmd
I=0 J=1 I=0 J=2 I=0 J=3 I=0.2 J=1.2 I=0.2 J=2.2 I=0.2 J=3.2 ..... I=2 J=? I=2 J=? I=2 J=?
Advertisements

Demonstration


Previous
#1097 Beecrowd Online Judge Solution 1097 Sequence IJ 3 - Solution in C, C++, Java, Python and C#
Next
#1099 Beecrowd Online Judge Solution 1099 Sum of Consecutive Odd Numbers II - Solution in C, C++, Java, Python and C#