Monday, May 30, 2016

URI Online Judge Solution 1098 || Sequence IJ 4

URI Online Judge | 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 SampleOutput 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=?

URI Online Judge Solution 1098 || Sequence IJ 4 in C Language


#include <stdio.h>
 
int main()
{
    float i, j, value;
    int temp, temp2;
 
    for (i = 0, j = 1, value = 0, temp = 0, temp2 = 0; i < 2.2; j++)
    {
        if(temp2 == 0){
            printf("I=%.0f J=%.0f\n", i, j);
        }else{
            printf("I=%.1f J=%.1f\n", i, j);
        }
 
        temp++;
 
        if(temp == 3){
            i += 0.2;
            value += 0.2;
            j = value;
            temp = 0;
            temp2++;
        }
 
        if(temp2 == 5)
            temp2 = 0;
    }
 
    return 0;
}


Download code from dropbox
Question link in URI


No comments:
Write comments

To know more about the problem, give us your valuable commment. We'll try to help you. Thanks

All rights reserved ©2016 -URI ONLINE JUDGE SOLUTION | Developed by Maniruzzaman Akash

© 2016 URI ONLINE JUDGE SOLUTION. Developed by Maniruzzaman Akash | Distributed By Gooyaabi Templates
Powered by Blogger.