当前位置: 代码迷 >> C语言 >> [求助]不知为什么错
  详细解决方案

[求助]不知为什么错

热度:120   发布时间:2007-01-05 15:43:31.0
[求助]不知为什么错

RPG (Role Play Games) is Vivid's favorite computer game type, such as Final Fantasy and Xian Jian Qi Xia Zhuan are both of this type. You may be even more familiar with it than Vivid is.

In these games, characters may have many attributes, e.g. physical force, attack ability, defence ability and so on. A lot of equipment types (weapon, armor, costume and so on) are also available in these games, and the equipments can alter (promotion or reduction) those character-attributes. E.g. Equipment with the attributes 10, 0, -10 means it will promote the first attribute of the character by 10, reduce the third attribute of the character by 10, and keep the second attribute unchanged.


In this problem, characters only have 3 attributes -- physical force, attack ability and defence ability. Lots of equipment types are available. You can choose at most one equipment from each type. Your goal is to make the lowest attribute as high as possible. If more than one choice exist, choose the one with higher value of the second lowest attribute. If there is still a tie, choose the one with higher highest attribute, you will be guaranteed that there is no tie then. For example, if one choice is 10, 20, 30 and the other one is 11, 11, 11, then the second will be chosen, for the lowest attribute of later is 11 while the lowest attribute of the former is 10. Another example, if one choice is 10, 20, 30 and another choice is 20, 10, 29, then the first will be chosen, for the lowest and the second lowest attributes of them are equal, and the highest attribute of the first is higher than the second.

Input:

The first line of the input is the total number of the test cases. Each test case begins will an integer T (the number of the equipment types, 1 <= T <= 16). Each block of equipment types will begins with an integer E (0 <= E <= 16), indicating the number of equipments of this type. Then E lines follows, each of them contains three integers A, B, C (all of them are in the range of [-100, 100]) indicating the effect to the character attributes (physical force, attack ability and defence ability).

Output:

Three integers should be printed in a single line for each test case, which are the final attribute values of physical force, attack ability and defence ability after equipment.

Sample Input:
2
1
2
10 20 30
11 11 11
1
2
10 20 30
20 10 29

Sample Output:
11 11 11
10 20 30

这是我们学校的online judge,为什么我提交时,系统显示错误(它说解决方案对,输入与题目要求不符).
请你们帮忙看一下.我的程序是:
#include<stdio.h>
void sort(int a[])
{ int t;
if(a[0]>a[1])t=a[0],a[0]=a[1],a[1]=t;
if(a[0]>a[2])t=a[0],a[0]=a[2],a[2]=t;
if(a[1]>a[2])t=a[1],a[1]=a[2],a[2]=t;
}
void deal(int s[],int t[])
{ int a[3],b[3],i,j;
for(i=0;i<3;++i){
a[i]=s[i];
b[i]=t[i];}
sort(a);
sort(b);
for(i=0;i<3;++i){
if(a[i]>b[i])
for(j=0;j<3;++j)
t[j]=s[j];
if(a[i]-b[i])break;}
}
main()
{ int re,i,j,t,a,b,k,s[16][3];
scanf("%d",&re);
for(i=0;i<re;++i){
scanf("%d",&a);
for(j=0;j<a;++j){
scanf("%d",&b);
for(t=0;t<b;++t)
for(k=0;k<3;++k)
scanf("%d",&s[t][k]);
if(b){
for(k=0;k<b-1;++k)
deal(s[k],s[k+1]);
for(k=0;k<3;++k)
printf("%d ",s[b-1][k]);
printf("\n");}}
}
}


----------------解决方案--------------------------------------------------------
能翻译下莫?
----------------解决方案--------------------------------------------------------
大家花点时间帮帮忙好吗?
----------------解决方案--------------------------------------------------------

看前面英语 我居然看懂了大概意思
感觉自己还不是文盲


----------------解决方案--------------------------------------------------------