|  | 
|  | 
| back to board | WA5 Help please, what's wrong?Or give some test cases.
 
 #include <iostream>
 using namespace std;
 
 struct figure {
 int type;
 int size;
 };
 
 bool (*figureFunction) (int, figure);
 
 bool circle (int holeSize, figure inManhole)
 {
 if( inManhole.type == 1 )
 return holeSize >= inManhole.size;
 return 2*holeSize >= inManhole.size;
 }
 
 bool triangle (int holeSize, figure inManhole)
 {
 if( inManhole.type == 3 ) return holeSize >= inManhole.size ;
 return holeSize > inManhole.size ;
 }
 
 bool square(int holeSize, figure inManhole)
 {
 switch(inManhole.type)
 {
 case 1: return sqrt(2)*holeSize >= 2*inManhole.size;
 case 2: return holeSize >= inManhole.size;
 case 3: return sqrt(2)*holeSize >= inManhole.size;
 default: break;
 }
 }
 
 int testHole( figure hole, figure* manhole, int count)
 {
 int willPut = 0;
 
 switch( hole.type ){
 case 1: figureFunction = &circle; break;
 case 2: figureFunction = □ break;
 case 3: figureFunction = ▵ break;
 default: break;
 }
 
 for( int i = 0; i<count; ++i )
 {
 if(figureFunction( hole.size, manhole[i] )) willPut++;
 }
 return willPut;
 }
 
 int main()
 {
 figure hole;
 cin>>hole.type>>hole.size;
 
 int count;
 cin>>count;
 figure* manhole = new figure[count];
 for( int i=0; i<count; ++i )
 {
 cin>>manhole[i].type>>manhole[i].size;
 }
 
 cout<< testHole( hole, manhole, count);
 
 delete manhole;
 
 return 0;
 }
 
 Edited by author 29.06.2012 18:56
Re: WA5 Posted by Nikita  2 May 2016 18:08WA#52 10
 1
 3 15
 Answer: 1
 
 WA#6
 3 10
 1
 3 11
 Answer: 1
 
 circle:   maxSize := 2 * a;
 minSize := 2 * a;
 square:   maxSize := a * sqrt(2);
 minSize := a;
 triangle: maxSize := a;
 minSize := a * sqrt(3) / 2;
Re: WA5 Thank yo so much ! (i forget about min size triangle :-) ) WA#5Re: WA5 WA5 - Try to put the circle into the square!!! | 
 | 
|