Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
哪位帮忙看下程序,为什么总是WA#include<iostream> #include<cstdlib> using namespace std; int a[16][3]; long color(int i,int b[]){ long sum=0; for(int j=0;j<3;j++) sum+= (a[i][j]-b[j])*(a[i][j]-b[j]); return sum; } int main(){ int t=0; while(t++<16) scanf("%d %d %d",&a[t][0],&a[t][1],&a[t][2]); int b[3]; while(scanf("%d %d %d",&b[0],&b[1],&b[2])) { if(b[0]==-1&&b[1]==-1&&b[2]==-1) return 0; long k=3000000;//初始化最小值 int tt; for(int i=0;i<16;++i) if(k>color(i,b)){k=color(i,b);tt=i;} printf("(%d,%d,%d) maps to (%d,%d,%d)\n", b[0],b[1],b[2],a[tt][0],a[tt][1],a[tt][2]); } return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator