Algorithm
Sequence IJ 3
Adapted by Neilor Tonin, URI Brazil
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 |
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
#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
#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