Monday 7 March 2016

Solution of URI 1097 :: Sequence IJ 3


Before seeing the solution make sure that you tried enough. Don’t paste the whole code, just find out the logic. If you stuck in trouble, just inform me on comment.

/**Bismillahir Rahmanir Rahim.**/

#include <stdio.h>
int main()
{
    int I,J,a=7,b;
    for(I=1;I<=9;I=I+2)
    {
        for(b=1,J=a;b<=3;J--,b++)
            printf("I=%d J=%d\n", I, J);
        a=a+2;
    }
    return 0;
}

2 comments:

  1. #include

    int main(int argc, char const *argv[])
    {
    int i, j, k = 0;

    for (i = 1; i <= 9; i += 2, k += 2)
    {
    for (j = 7 + k; j >= 5 + k; j--)
    {
    printf("I=%d J=%d\n", i, j);
    }

    }

    return 0;
    }

    I think this is easier to understand

    ReplyDelete
  2. #include
    int main()
    {
    int I=1,J=7;

    while(I!=11)
    {

    printf("I=%d J=%d\n",I,J);

    J=J-1;
    printf("I=%d J=%d\n",I,J);
    J=J-1;
    printf("I=%d J=%d\n",I,J);
    I=I+2;
    J=J+4;




    }
    }

    ReplyDelete

Note: only a member of this blog may post a comment.