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=11; scanf("%s", &T); for(x=0;x<=11;x++) { for(y=0; y<=11; y++) scanf("%lf", &M[x][y]); } for(z=1; z<=11;z++) { for(C=11; C>=p;C--) a+=M[z][C]; p--; } if(T[0]=='S') printf("%.1lf\n",a); else if(T[0]=='M') { a=a/66.0; printf("%.1lf\n",a); } return 0; }
#include
ReplyDeleteint main()
{
int i,j,d=11;
float a[12][12],s=0.0,m=0.0,x=0.0;
char c;
scanf("%c",&c);
for(i=0; i<=11; i++)
{
for(j=0; j<=11; j++)
{
scanf("%f",&a[i][j]);
if( i>=1 && j>d )
{
s=s+a[i][j];
m++;
}
}
d--;
}
if(c=='S')
{
printf("%.1f\n",s);
}
else if(c=='M')
{
x=s/m;
printf("%.1f\n",x);
}
return 0;
}
This comment has been removed by the author.
ReplyDelete