Tuesday 19 January 2016

Solution of URI 1187 :: Superior Area


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()
{
    double a=0.0, M[12][12];
    char T[2];
    int C,x,y,z,p=10,q=1;
    scanf("%s", &T);
    for(x=0;x<=11;x++)
    {
        for(y=0; y<=11; y++)
            scanf("%lf", &M[x][y]);
    }
    for(z=0; z<=4;z++)
    {
        for(C=q; C<=p;C++) a+=M[z][C];

            p--;
            q++;
    }
    if(T[0]=='S')
        printf("%.1lf\n",a);
    else if(T[0]=='M')
    {
        a=a/30.0;
        printf("%.1lf\n",a);
    }
    return 0;
}

3 comments:

  1. #include
    int main()
    {
    double a[12][12],sum=0;
    int i,j,x=11;
    char d;
    scanf("%c",&d);
    for(i=0;i<12;i++)
    for(j=0;j<12;j++)
    scanf("%lf",&a[i][j]);
    for(i=0;i<=4;i++)
    {

    for(j=i+1;j<12-(i+1);j++)
    sum+=a[i][j];
    x--;

    }
    if(d=='S')
    printf("%.1lf\n",sum);
    else if(d=='M')
    printf("%.1lf\n",sum/30);
    return 0;
    }

    ReplyDelete
  2. where is the mistake?

    #include
    int main()
    {
    double M[12][12],sum=0.0;
    int i,j,x,y,p=11;
    char T[2];

    scanf("%s", &T);
    for(i=0; i<=11; i++)
    {
    for(j=0; j<=11; j++)
    scanf("%lf", &M[i][j]);
    }

    for(x=1; x<=11; x++)
    {
    for(y=11; y<=p; y--)
    {
    sum+=M[x][y];
    p--;
    }
    }

    if(T[0]=='S')
    printf("%.1lf\n",sum);
    else if(T[0]=='M')
    {
    sum=sum/66.0;
    printf("%.1lf\n",sum);
    }

    return 0;
    }

    ReplyDelete

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