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 <stdio.h> #include <math.h> int main() { int a[20]={0},b[20]={0},c[20]={0}; int g,h,j,flage; long int min; int i; for(i=1;i<=16;i++) scanf("%d%d%d",&a[i],&b[i],&c[i]); while(3==scanf("%d%d%d",&g,&h,&j)) { flage=0; if(g==-1&&h==-1&&j==-1) break; min=(abs(g-a[1])*abs(g-a[1])+abs(h-b[1])*abs(h-b[1])+abs(j-c[1])*abs(j-c[1])); for(i=1;i<=16;i++) { if(min>=(abs(g-a[i])*abs(g-a[i])+abs(h-b[i])*abs(h-b[i])+abs(j-c[i])*abs(j-c[i]))) { min=(abs(g-a[i])*abs(g-a[i])+abs(h-b[i])*abs(h-b[i])+abs(j-c[i])*abs(j-c[i])); flage=i; } } printf("(%d,%d,%d) maps to (%d,%d,%d)\n",g,h,j,a[flage],b[flage],c[flage]); } return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator