1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
| int myMax(int a,int b){ if(a>b) return a; else return b; } int main(){ int a[4],X,Y,max,res; for(int i=0;i<4;i++){ cin >> a[i]; if(max<a[i]) max=a[i]; } p.r(100,100).up(); p.moveTo(-50,50); for(int i=0;i<4;i++){ p.rt(90).o(a[i]); if(a[i]==max){ X=getX(); Y=getY(); res=i; } p.fd(100); } if(a[res]>a[(res+1)%4]+100 && a[res]>a[(res+2)%4]+100&&a[res]>a[(res+3)%4]+100){ p.moveTo(X,Y); p.r(max*2,max*2); }else{ if(a[(res+1)%4]<a[(res+2)%4] && a[(res+2)%4] > a[(res+3)%4]){ cout << "对角线"; p.moveTo(X/abs(X)*(50+max-(a[res]+a[(res+2)%4]+100)/2.0),Y/abs(Y)*(50+max-(a[res]+a[(res+2)%4]+100)/2.0)); p.r((a[res]+a[(res+2)%4]+100),(a[res]+a[(res+2)%4]+100)); }else{ if((res%2==0&&a[(res+1)%4]>a[(res+2)%4] && a[(res+1)%4] > a[(res+3)%4])||(res%2==1&&a[(res+3)%4]>a[(res+1)%4] && a[(res+3)%4] > a[(res+2)%4])){ p.moveTo(X/abs(X)*(50+max-(max+a[(res+1+2*(res%2))%4]+100)/2.0),Y/abs(Y)*(50+max-(max+myMax(a[(res+2-res%2)%4],a[(res+3-res%2)%4])+100)/2.0)); p.r(max+a[(res+1+2*(res%2))%4]+100,max+myMax(a[(res+2-res%2)%4],a[(res+3-res%2)%4])+100); }else{ p.moveTo(X/abs(X)*(50+max-(max+myMax(a[(res+1+res%2)%4],a[(res+2+res%2)%4])+100)/2.0),Y/abs(Y)*(50+max-(max+a[(res+3-2*(res%2))%4]+100)/2.0)); p.r(max+myMax(a[(res+1+res%2)%4],a[(res+2+res%2)%4])+100,max+a[(res+3-2*(res%2))%4]+100); }
} } return 0; }
|