杭电1069

这题只做到排序,后面的变量,如全局变量的值还没做完。因为本题需要用到动态规划,还没进行进一步的学习。暂置。

#include<stdio.h>
struct block
{
int length;
int width;
int height;
};
int main()
{
int n;
int count=0;
while(scanf("%d",&n)!=EOF&&n)
{
count++;
int a,b,c;
int t;
struct block k[3];
int max;
while(n–)
{
scanf("%d%d%d",&a,&b,&c);
if(a>b)
{
if(c>b)
{
if(a>c)
{
t=b;
b=c;
c=t;
}
else
{
t=a;
a=c;
c=t;
t=b;
b=c;
c=t;
}
}
}
else
{
if(a>c)
{
t=b;
b=a;
a=t;
}
else
{
if(b>c)
{
t=a;
a=b;
b=t;
t=b;
b=c;
c=t;
}
else
{
t=c;
c=a;
a=t;
}
}
}
k[0].length=a;
k[0].width=b;
k[0].height=c;
k[1].length=a;
k[1].width=c;
k[1].height=b;
k[2].length=b;
k[2].width=c;
k[2].height=a;
max=k[0].height;
int i;
for(i=1;i<3;i++)
{
if(k[i].lengthk[i].width<k[i-1].lengthk[i-1].width)
max+=k[i].height;
}
}
printf(“Case %d:maximum height = %d\n”,count,max);
}
return 0;
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值