[URI Online Judge] – 1097 – Sequence IJ 3

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

Input

This problem has no input.

Output

Print the sequence like example below.

Sample Input Sample Output
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

Solution:

#include <cstdio>
int main(){
 int i = 1, j = 7;
 while (i <= 9){
 printf("I=%d J=%d\n", i, j--);
 printf("I=%d J=%d\n", i, j--);
 printf("I=%d J=%d\n", i, j--);
 i += 2;
 j += 5;
 }
 return 0;
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s