Friday 15 January 2016

Solution of URI 1858 :: Theon's Answer


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=0,e=1;
    scanf("%d", &a);
    int ara[a];
    for(b=0; b<a; b++)
        scanf("%d", &ara[b]);
    c=ara[d];
    for(d=0; d<a; d++)
    {
        if(ara[d]<c)
        {
            c=ara[d];
            e=d+1;
        }

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

2 comments:

  1. Thank you brother. Nice solution .

    ReplyDelete
  2. I used to initialize with 0. In this case why it shows 10% error if initialize e=0 instead of e=1?

    ReplyDelete

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