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 yangchong12 at 2007-08-07 12:23:14 on Problem 1046
为什么是wrong answer !!!!!!!!

#include <iostream>
#include <math.h>
using namespace std;
int r[10001],g[10001],b[10001];
int main(int argc, char *argv[])
{
    int R[16],G[16],B[16];
    for(int i=0;i<16;i++)
    cin>>R[i]>>G[i]>>B[i];
    double d[10001];
    int k=0;
    cin>>r[0]>>g[0]>>b[0];
    while(r[k]!=-1&&g[k]!=-1&&b[k]!=-1){
    int j=0;
    while(j<16){
    d[j]=sqrt(pow(r[k]-R[j],2)+pow(g[k]-G[j],2)+pow(b[k]-B[j],2));
    j++;
    }
    int c;
    double min=d[0];
    for(int l=0;l<16;l++)
    {
    if(d[l]<min){
    min=d[l];
    c=l;
    }
    }
    printf("(%d,%d,%d) maps to (%d,%d,%d)\n",r[k],g[k],b[k],R[c],G[c],B[c]);
    k++;
    cin>>r[k]>>g[k]>>b[k];
    }
    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