Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<math.h>
- struct node{
- double x;
- double y;
- };
- double distace(double x1, double y1, double x2, double y2)
- {
- double d;
- d=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
- return d;
- }
- double slop(double x1, double y1, double x2, double y2)
- {
- double m;
- if(x1==x2)
- m=10009;
- else
- m=(y2-y1)/(x2-x1);
- return m;
- }
- int main()
- {
- int n,i;
- double ab,bc,cd,da;
- double abm,bcm,cdm,dam;
- struct node a,b,c,d;
- freopen("input.txt","r",stdin);
- scanf("%d",&n);
- for(i=1;i<=n;i++){
- scanf("%lf %lf",&a.x,&a.y);
- scanf("%lf %lf",&b.x,&b.y);
- scanf("%lf %lf",&c.x,&c.y);
- scanf("%lf %lf",&d.x,&d.y);
- printf("Case %d: ",i);
- ab = distace(a.x, a.y, b.x, b.y);
- bc = distace(b.x, b.y, c.x, c.y);
- cd = distace(d.x, d.y, c.x, c.y);
- da = distace(a.x, a.y, d.x, d.y);
- abm = slop(a.x, a.y, b.x, b.y);
- bcm = slop(b.x, b.y, c.x, c.y);
- cdm = slop(d.x, d.y, c.x, c.y);
- dam = slop(a.x, a.y, d.x, d.y);
- if(ab==cd && bc==da){
- if(ab==bc){
- if((abm==10009 && bcm==0)||(abm==0 && bcm==10009))
- printf("Square\n");
- else if((bcm!=10009 && abm!=10009) && abm==-(1/bcm))
- printf("Square\n");
- else if(abm==cdm && bcm==dam)
- printf("Rhombus\n");
- }
- else{
- if((abm==10009 && bcm==0)||(abm==0 && bcm==10009))
- printf("Rectangle\n");
- else if((bcm!=10009 && abm!=10009) && ((abm==-(1/bcm))||(bcm==-(1/abm))))
- printf("Rectangle\n");
- else if(abm==cdm && bcm==dam)
- printf("Parallelogram\n");
- }
- }
- else{
- if(abm==cdm || bcm==dam)
- printf("Trapezium\n");
- else{
- ab = distace(a.x, a.y, b.x, b.y);
- bc = distace(b.x, b.y, d.x, d.y);
- cd = distace(c.x, c.y, d.x, d.y);
- da = distace(a.x, a.y, c.x, c.y);
- abm = slop(a.x, a.y, b.x, b.y);
- bcm = slop(b.x, b.y, d.x, d.y);
- cdm = slop(c.x, c.y, d.x, d.y);
- dam = slop(a.x, a.y, c.x, c.y);
- if(ab==cd && bc==da){
- if(ab==bc){
- if((abm==10009 && bcm==0)||(abm==0 && bcm==10009))
- printf("Square\n");
- else if((bcm!=10009 && abm!=10009) && abm==-(1/bcm))
- printf("Square\n");
- else if(abm==cdm && bcm==dam)
- printf("Rhombus\n");
- }
- else{
- if((abm==10009 && bcm==0)||(abm==0 && bcm==10009))
- printf("Rectangle\n");
- else if((bcm!=10009 && abm!=10009) && ((abm==-(1/bcm))||(bcm==-(1/abm))))
- printf("Rectangle\n");
- else if(abm==cdm && bcm==dam)
- printf("Parallelogram\n");
- }
- }
- else{
- if(abm==cdm || bcm==dam)
- printf("Trapezium\n");
- else{
- ab = distace(a.x, a.y, c.x, c.y);
- bc = distace(c.x, c.y, b.x, b.y);
- cd = distace(d.x, d.y, b.x, b.y);
- da = distace(a.x, a.y, d.x, d.y);
- abm = slop(a.x, a.y, c.x, c.y);
- bcm = slop(c.x, c.y, b.x, b.y);
- cdm = slop(d.x, d.y, b.x, b.y);
- dam = slop(a.x, a.y, d.x, d.y);
- if(ab==cd && bc==da){
- if(ab==bc){
- if((abm==10009 && bcm==0)||(abm==0 && bcm==10009))
- printf("Square\n");
- else if((bcm!=10009 && abm!=10009) && abm==-(1/bcm))
- printf("Square\n");
- else if(abm==cdm && bcm==dam)
- printf("Rhombus\n");
- }
- else{
- if((abm==10009 && bcm==0)||(abm==0 && bcm==10009))
- printf("Rectangle\n");
- else if((bcm!=10009 && abm!=10009) && ((abm==-(1/bcm))||(bcm==-(1/abm))))
- printf("Rectangle\n");
- else if(abm==cdm && bcm==dam)
- printf("Parallelogram\n");
- }
- }
- else{
- if(abm==cdm || bcm==dam)
- printf("Trapezium\n");
- else{
- ab = distace(a.x, a.y, c.x, c.y);
- bc = distace(c.x, c.y, d.x, d.y);
- cd = distace(b.x, b.y, d.x, d.y);
- da = distace(a.x, a.y, b.x, b.y);
- abm = slop(a.x, a.y, c.x, c.y);
- bcm = slop(c.x, c.y, d.x, d.y);
- cdm = slop(b.x, b.y, d.x, d.y);
- dam = slop(a.x, a.y, b.x, b.y);
- if(ab==cd && bc==da){
- if(ab==bc){
- if((abm==10009 && bcm==0)||(abm==0 && bcm==10009))
- printf("Square\n");
- else if((bcm!=10009 && abm!=10009) && abm==-(1/bcm))
- printf("Square\n");
- else if(abm==cdm && bcm==dam)
- printf("Rhombus\n");
- }
- else{
- if((abm==10009 && bcm==0)||(abm==0 && bcm==10009))
- printf("Rectangle\n");
- else if((bcm!=10009 && abm!=10009) && ((abm==-(1/bcm))||(bcm==-(1/abm))))
- printf("Rectangle\n");
- else if(abm==cdm && bcm==dam)
- printf("Parallelogram\n");
- }
- }
- else{
- if(abm==cdm || bcm==dam)
- printf("Trapezium\n");
- else{
- ab = distace(a.x, a.y, d.x, d.y);
- bc = distace(d.x, d.y, b.x, b.y);
- cd = distace(c.x, c.y, b.x, b.y);
- da = distace(a.x, a.y, c.x, c.y);
- abm = slop(a.x, a.y, d.x, d.y);
- bcm = slop(d.x, d.y, b.x, b.y);
- cdm = slop(c.x, c.y, b.x, b.y);
- dam = slop(a.x, a.y, c.x, c.y);
- if(ab==cd && bc==da){
- if(ab==bc){
- if((abm==10009 && bcm==0)||(abm==0 && bcm==10009))
- printf("Square\n");
- else if((bcm!=10009 && abm!=10009) && abm==-(1/bcm))
- printf("Square\n");
- else if(abm==cdm && bcm==dam)
- printf("Rhombus\n");
- }
- else{
- if((abm==10009 && bcm==0)||(abm==0 && bcm==10009))
- printf("Rectangle\n");
- else if((bcm!=10009 && abm!=10009) && ((abm==-(1/bcm))||(bcm==-(1/abm))))
- printf("Rectangle\n");
- else if(abm==cdm && bcm==dam)
- printf("Parallelogram\n");
- }
- }
- else{
- if(abm==cdm || bcm==dam)
- printf("Trapezium\n");
- else
- printf("Ordinary Quadrilateral\n");
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement