CodeChef submission 129719 (C++ 4.0.0-8) plaintext list. Status: CE, problem J7, contest NOV09. By sandip4848 (sandip singh), 2009-11-10 22:15:28.
#include<iostream.h> #include<math.h> float dimensions(int a,int b) { if(a>0&&b>0) { float x1,y1,x2,y2,z1,z2,k,v1,v2,l,r,s,p,m; m=(a*a/4)-6*b; z1=((a/2)+p)/6; z2=((a/2)-p)/6; v1=z1*z1*z1-a*z1*z1/4+b*z1/2; v2=z2*z2*z2-a*z2*z2/4+b*z2/2; if(v1>v2) { l=a/4-z1; k=z1*z1-a*z1/4+b/2; x1=(l+r)/2; y1=(l-r)/2; } else { k=z2*z2-a*z2/4+b/2; l=a/4-z2; x2=(l+r)/2; y2=(l-r)/2; } if(v1>v2) return v1; else return v2; } } void main() { int p,s,n,i; float v; cout<<"enter the no of cases"; cin>>n; for(i=1;i<=n;i++) { cout<<"enter the value of perimeter and surface area"; cin>>p>>s; v=dimensions(p,s); cout<<"\nmax vol is"<<v<<endl; } }
Comments

