Sunday, 27 March 2016

Solution of URI 1144 :: Logical Sequence


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 a,b,c,d,e,f;
    scanf("%d", &a);
    for(b=1; b<=a; b++)
    {
        c=b*b;
        d=b*b*b;
        printf("%d %d %d\n",b,c,d);
        e=c+1;
        f=d+1;
        printf("%d %d %d\n",b,e,f);
    }
    return 0;
}

3 comments:

  1. Hi, my code is giving 'Presentation Error' and I can't figure out why. Can you help me?
    """
    a=0
    N=int(input())
    if 1<N<1000:
    for i in range(1,N+1):
    for k in range(1,4):
    print(i**k,end=' ')
    print()

    for j in range(1,4):
    if j==2 or j==3:
    a=i**j+1
    print(a, end=' ')
    else:
    print(i**j,end=' ')
    a=0
    print()
    """

    ReplyDelete
  2. #include
    int main()
    {
    int N,q,r,i;
    scanf("%d", &N);
    for(i=1;i<=N;i++)
    {
    q=i*i;
    r=i*i*i;
    printf("%d %d %d\n",i,q,r);
    printf("%d %d %d\n",i,q+1,r+1);
    }
    return 0;
    }

    ReplyDelete
  3. #include
    int main()
    {
    int n,i;
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {
    printf("%d %d %d\n",i,i*i,i*i*i);
    printf("%d %d %d\n",i,(i*i)+1,(i*i*i)+1);
    }
    return 0;
    }

    ReplyDelete

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