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

疯了!!在VC上正确却提交错误 !!!很不理解,逼疯了,大家帮我看看 !!1046,代码在下面!

Posted by li4951 at 2008-10-30 19:54:18
#include<iostream>
#include<cmath>
using namespace std;

typedef struct value{
	double R;
	double G;
	double B;
}V;

int main()
{
	int i = 0;
	int num=0;
	V standard[16];
	double result;
	double temp;
	for( i =0 ; i < 16 ; i++ )
	{
		 cin >> standard[i].R >> standard[i].G >> standard[i].B;
	}
	V incolor;
	while(cin >> incolor.R >> incolor.G >> incolor.B)
	{
		if(incolor.R==(-1))
                {
                       break;
                }
		result = sqrt  ( (standard[0].R-incolor.R)*(standard[0].R-incolor.R) + 
			(standard[0].G-incolor.G)*(standard[0].G-incolor.G) + 
			(standard[0].B-incolor.B)*(standard[0].B-incolor.B) )  ;
		for( i = 1 ; i < 16 ; i++ )
		{
			 temp = sqrt( (standard[i].R-incolor.R)*(standard[i].R-incolor.R) + 
			 (standard[i].G-incolor.G)*(standard[i].G-incolor.G) + 
			 (standard[i].B-incolor.B)*(standard[i].B-incolor.B) );
			if(temp < result)
			{
				 result = temp;
				 num = i;
			}
		}
	 cout << "(" << incolor.R <<","<< incolor.G <<","<< incolor.B<<") maps to (" << standard[num].R <<","<< standard[num].G <<","<< standard[num].B<<")"<<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