[URI Online Judge] – 1095 – Sequence IJ 1

Do a program that print the sequence like following example.

Input

This problem has no input.

Output

Print the sequence like example below.

Sample Input Sample Output
I=1 J=60
I=4 J=55
I=7 J=50

I=? J=0

My solution:

#include <cstdio>
int main(){
 int i = 1, j = 60;
 while (j != 0){
 printf("I=%d J=%d\n", i, j);
 i += 3;
 j -= 5;
 }
 printf("I=%d J=%d\n", i, j);
 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