Sunday 27 March 2016

Solution of URI 1150 :: Exceeding Z


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=0,x,z;
    scanf("%d", &x);
    do{
        scanf("%d", &z);
    }
    while(x>=z);
    for(a=x,b=0; b<z; a++)
    {
        b+=a;
        c++;
    }
    printf("%d\n", c);
    return 0;
}

2 comments:

  1. int main()
    {

    int x,y;
    int num=0,sum=0;
    scanf("%d",&x);

    do
    scanf("%d",&y);
    while(x>=y);

    while(y>sum)
    {

    sum=sum+x;
    x++;
    num++;

    }

    printf("%d\n",num);

    return 0;
    }

    //PLs check my code

    ReplyDelete
  2. #include

    int main()
    {
    int x,z,n=0,j,i,k,sum;
    scanf ("%d",&x);
    do
    {
    scanf ("%d",&z);
    }while(x>=z);
    for(j=x;jz)
    {
    n++;
    }
    j=i++;

    }
    printf ("%d\n",n);
    return 0;
    }

    where is my fault???
    plz help me to find my wrong place ...

    ReplyDelete

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