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

帮忙看看为什么总是wrong answer吧

Posted by neptune841231 at 2003-12-19 17:29:44 on Problem 1046
#include <iostream.h>
#include <math.h>
    float min(float a,float b)
	{  float c;
	   c=a<b? a:b;
	   return (c);
	}
	void main(){
		struct color
		{   int R;
		    int G;
			int B;
		}color[16], color1, point;
		int n;
		int i;
		float D[16];
		double dis;
		for (n=0; n<16; n++){
			cin>>color[n].R>>color[n].G>>color[n].B;
		}
		while (1){
			cin>>color1.R>>color1.G>>color1.B; 
			if (color1.R==-1&&color1.G==-1&&color1.B==-1)
				break;
			else {
			    
			    dis=sqrt(double((color[0].R-color1.R)*(color[0].R-color1.R)+(color[0].G-color1.G)*(color[0].G-color1.G)+(color[0].B-color1.B)*(color[0].B-color1.B)));
				for (i=0; i<16; i++){
			    D[i]=sqrt((color[i].R-color1.R)*(color[i].R-color1.R)+(color[i].G-color1.G)*(color[i].G-color1.G)+(color[i].B-color1.B)*(color[i].B-color1.B));
				if (D[i]<=dis)
				{point=color[i];}
				dis=min(D[i], dis);
				}
	            cout<<"("<<color1.R<<","<<color1.G<<","<<color1.B<<")"<<" maps to ("<<point.R<<","<<point.G<<","<<point.B<<")"<<endl;
			}
			
		}
	}
我在自己的机子上运行完全正确啊

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