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 Ly86 at 2011-01-21 15:23:04 on Problem 1254
#include <iostream>
#include <stdio.h>
#include <math.h>
#define FOR(i,s,e) for (int (i)=(s); (i)<(e); (i)++)
#define ROUNT(x) ((int)(10000*(x)+0.5))/10000.0
const double PI = 3.1415926535897;
using namespace std;
double a[3];
double b[3];
double c[3];
void get(double x, double y, double p,int i)
{
    if (p == 0 || p == 180)
    {
        a[i] = 1;
        b[i] = 0;
        c[i] = x*1.0;
    }
    else
    {
        p = p/180*PI;
        if (p >= 0 && p <= PI)
        p = PI/2 - p;
        else
        p = 3*PI/2 - p;
         a[i] = -1 * tan(p);
        b[i] = 1;
        c[i] = x*a[i]+b[i]*y;
    }
}
int main()
{
   // freopen("in.txt","r",stdin);
    int t;
    double xx,yy,pp;
    double x,y;
    scanf("%d",&t);
    while (t--)
    {
        FOR(i,1,3)
        {
            scanf("%lf%lf%lf",&xx,&yy,&pp);
            get(xx,yy,pp,i);
        }
        x = (c[1]*b[2]-c[2]*b[1])/(a[1]*b[2]-a[2]*b[1]);
        y = (c[1]*a[2]-c[2]*a[1])/(b[1]*a[2]-b[2]*a[1]);
         printf("%.4lf %.4lf\n",ROUNT(x),ROUNT(y));
    }
	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