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

错哪里啊????yunsile

Posted by y_zou at 2005-02-15 01:27:11 on Problem 1046
#include<iostream>

using namespace std;

typedef struct cell
{

	int _R;
	int _G;
	int _B;
}Cell;

int main()
{

	int r,g,b,j = 0,i,k;
	long D[1024]={0};
	Cell Rgb[16];
    

	for(i = 0;i<16;i++)
		cin>>Rgb[i]._R>>Rgb[i]._G>>Rgb[i]._B;
        
    
	
	 cin>>r>>g>>b;
	 while(r!=-1&&b!=-1&&g!=-1){
	 
       for(j = 0; j<16;j++)   
		D[j] = (Rgb[j]._R - r)*(Rgb[j]._R - r) + (Rgb[j]._G - g)*(Rgb[j]._G - g) + (Rgb[j]._B-b)*(Rgb[j]._B - b);
	 

    for(j=0,k=0;j<16;j++)
		{
			if(D[j]<=D[k])
				k=j;
		}
	 
        cout<<"("<<r<<","<<g<<","<<b<<") maps to ("<<Rgb[k]._R<<","<<Rgb[k]._G<<","<<Rgb[k]._B<<")"<<endl;
	  
        cin>>r>>g>>b;
	 }
	 
	 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