poj 1046 麻烦各位大大师给看一下哪错了,谢谢

来源:百度知道 编辑:UC知道 时间:2024/09/20 20:44:43
#include "stdio.h"
#include "math.h"
main()
{int t[16][3];
int s[3],dd[16];
int i,j,p,u[100],r,w;
float d[16],temp;
int x[100][3];
for(i=0;i<16;i++)
for(j=0;j<3;j++)
scanf("%d",&t[i][j]);
for(r=0;r<100;r++)
{ for(j=0;j<3;j++)
scanf("%d",&s[j]);
if(s[0]==-1) break;

for(i=0;i<16;i++)
{ d[i]=0;
for(j=0;j<3;j++)
d[i]=d[i]+(t[i][j]-s[j])*(t[i][j]-s[j]);
if(i==0) temp=d[i];
if(temp<d[i]) {temp=d[i];u[r]=i;}

}

x[r][0]=s[0];
x[r][1]=s[1];
x[r][2]=s[2];
}
w=r;
for(r=0;r<w;r++)
printf("(%d,%d,%d) maps to (%d,%d,%d)\n",x[r][0],x[r][1],x[r][2],t[u[r]][0],t[u[r]][1],t[u[r]][2]);

}
Input
The input is a list of RGB colors, one color per line, specified as three integers from 0 to 255 delimited by a single space. The

没有题目。。。。。

程序语法没问题,编译可以通过,可以开始运行。

输入的数据量太多,最好用数据文件,手功一遍遍打太麻烦。
for(i=0;i<16;i++) for(j=0;j<3;j++) scanf("%d",&t[i][j]);
这里要打入48个数,i 是行号,j是列号,不能搞错。
这还好。

for(r=0;r<100;r++)
{ for(j=0;j<3;j++) scanf("%d",&s[j]);
。。。
};
要循环100次,每次输入3个数。

计算什么你没说。计算有结果,是不是你要的,无从得知。