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 liugan160 at 2014-10-30 17:00:00 on Problem 1039
#include<iostream>
#include<fstream>
#include<iomanip>
using namespace std;
int m,n,k;
double k1[100],k2[100],x[21],y[21];
double b1[100],b2[100];
double kb[21][21],kt[21][21],bb[21][21],bt[21][21];
int main()
{
    int a,b,c;
   double d,e;
    //ifstream cin("Pipe.in");
    //ofstream cout("Pipe.out");
    while(cin>>n && n)
    {
        for(a=1;a<=n;a++)
        {
            cin>>x[a]>>y[a];
            if(a==1) continue;
            for(b=1;b<=a-1;b++)
            {
                kt[a-1][b]=(y[a]-y[b]+1)/(x[a]-x[b]);
                bt[a-1][b]=y[b]-1-x[b]*kt[a-1][b];
                kb[a-1][b]=(y[a]-1-y[b])/(x[a]-x[b]);
                bb[a-1][b]=y[b]-x[b]*kb[a-1][b];
            }
            k1[a-1]=(y[a]-y[a-1])/(x[a]-x[a-1]);
            b1[a-1]=y[a]-x[a]*k1[a-1];
            k2[a-1]=k1[a-1];
            b2[a-1]=b1[a-1]-1;
        }
        if(n<=2) {cout<<"Through all the pipe."; continue;}
        e=9999999;
        for(a=2;a<=n-1;a++)
        {
            for(b=1;b<=a-1;b++)
            for(c=1;c<=b;c++)
            {
                if(kt[b][c]!=k2[a])
                {
                    d=(b2[a]-bt[b][c])/(kt[b][c]-k2[a]);
                    if(d>x[a] && d<x[a+1])
                    if(e>d) e=d;
                }
                if(kb[b][c]!=k1[a])
                {
                    d=(b1[a]-bb[b][c])/(kb[b][c]-k1[a]);
                    if(d>x[a] && d<x[a+1])
                    if(e>d) e=d;
                }
            }
            if(e<9999999) break;
        }
        if(e<9999999) cout<<fixed<<setprecision(2)<<e;
        else cout<<"Through all the pipe.";
        cout<<endl;
    }
    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