Friday 25 March 2016

Solution of LIGHT OJ 1001 :: Opposite Task


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

6 comments:

  1. problem,, Your code will produce a duplicate result

    ReplyDelete
  2. your code will generate duplicate answer.



    ReplyDelete
  3. #include

    #include
    int main()
    {
    int tc,n,num,a,b;
    scanf("%d",&n);
    for(tc=1;tc<=n;tc++){
    scanf("%d",&num);
    label1:
    int a =rand()%100;
    int b =rand()%100;
    while((a+b)!=num)
    goto label1;

    printf("Case %d: %d %d",tc,a,b);
    }
    return 0;
    }



    What is the problem in my code ??

    ReplyDelete
  4. #include

    #include
    int main()
    {
    int tc,n,num,a,b;
    scanf("%d",&n);
    for(tc=1;tc<=n;tc++){
    scanf("%d",&num);
    label1:
    int a =rand()%100;
    int b =rand()%100;
    while((a+b)!=num)
    goto label1;

    printf("Case %d: %d %d",tc,a,b);
    }
    return 0;
    }



    What is the problem in my code ??

    ReplyDelete

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