Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

不知道那里错了....高手进来看看啊...

Posted by P_sam at 2009-09-03 15:48:52 on Problem 1269
#include"stdio.h"
struct line{
       double x1,y1;
       double x2,y2;
       }l1,l2;
double a1,b1,c1,k1,a2,b2,c2,k2;       
double calculate(struct line l1,struct line l2){ 
       if(l1.x1==l1.x2)
       {
          a1=1;b1=0;c1=-l1.x1;
       }
       else  if(l1.y1==l1.y2)
       {
          a1=0;b1=1;c1=-l1.y1;
       } 
       else {
            k1=(l1.y1-l1.y2)/(l1.x1-l1.x2);
            a1=1;b1=-1/k1;c1=(-l1.x2*k1+l1.y2)/k1;
            } 
       if(l2.x1==l2.x2)
       {
          a2=1;b2=0;c2=-l2.x1;
       }
       else  if(l2.y1==l2.y2)
       {
          a2=0;b2=1;c2=-l2.y1;
       } 
       else {
            k2=(l2.y1-l2.y2)/(l2.x1-l2.x2);
            a2=1;b2=-1/k2;c2=(-l2.x1*k2+l2.y1)/k2;
            }
            }
int main(){
    int N;
    scanf("%d",&N);
    printf("INTERSECTING LINES OUTPUT\n");
    while(N--){
       scanf("%lf %lf %lf %lf %lf %lf %lf %lf",&l1.x1,&l1.y1,&l1.x2,&l1.y2,&l2.x1,&l2.y1,&l2.x2,&l2.y2);
    calculate(l1,l2);
     if(a1 == a2 && b1 == b2){
          if(c1 == c2) printf("LINE\n");
          else printf("NONE\n");
     }
     else {
       printf("POINT ");
       printf("%.2lf %.2lf\n",(b1*c2 - c1*b2)/(a1*b2 - b1*a2),(a1*c2 - c1*a2)/(b1*a2 - a1*b2));
       }
       }
       printf("END OF OUTPUT\n");
       return 0;
       }

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator