您的位置:首页 > 其它

zoj 1745 又是简单题

2010-08-03 15:16 176 查看
////////////////////////////////////////////////////////

// ZOJ:1745

// 本题出现最多的就是输出格式错误的问题,被题目调戏了

///////////////////////////////////////////////////////

#include "stdio.h"

#include "math.h"

int main(void)

{

int cookiepos[500] = {0};

int pos[500][500] = {0};

int prepos;

int dis;

int i = 0;

int k;

int m;

int x, y;

while (scanf("%d", &cookiepos[i]))

{

if (cookiepos[i] >= 5280)

{

break;

}

k = 0;

while (scanf("%d", &pos[i][k]))

{

if (cookiepos[i] == pos[i][k])

{

break;

}

k++;

}

i++;

}

m = i;

x = 0;

while (m-- > 0)

{

y = 0;

dis = abs(0 - cookiepos[x]);

prepos = 0;

while (pos[x][y] != cookiepos[x])

{

if (abs(pos[x][y] - cookiepos[x]) > dis)

{

printf("Moving from %d to %d: colder./n", prepos, pos[x][y]);

prepos = pos[x][y];

dis = abs(pos[x][y] - cookiepos[x]);

}

else if (abs(pos[x][y] - cookiepos[x]) < dis)

{

printf("Moving from %d to %d: warmer./n", prepos, pos[x][y]);

prepos = pos[x][y];

dis = abs(pos[x][y] - cookiepos[x]);

}

else if (abs(pos[x][y] - cookiepos[x]) == dis)

{

printf("Moving from %d to %d: same./n", prepos, pos[x][y]);

prepos = pos[x][y];

dis = abs(pos[x][y] - cookiepos[x]);

}

y++;

}

printf("Moving from %d to %d: found it!/n", prepos, pos[x][y]);

if (m >= 1)

{

printf("/n");

}

x++;

}

return 0;

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: