-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFalling Ant.cpp
More file actions
61 lines (55 loc) · 1.29 KB
/
Falling Ant.cpp
File metadata and controls
61 lines (55 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include<iostream>
#include<cstdio>
using namespace std;
class ant{
int L;
int W;
public:
int H;
int Vol;
void set(int L,int W,int H)
{
this->L=L,this->W=W,this->H=H;
Vol=L*H*W;
}
};
int main()
{
int tc;
ant *arabase;
while(1==scanf("%d",&tc))
{
if(!tc) break;
arabase=new ant[tc];
for(int l=0;l<tc;l++)
{
int i,j,k;
cin>>i>>j>>k;
arabase[l].set(i,j,k);
}
for(int l=tc;l>0;l--)
{
for(int l1=1;l1<l;l1++)
{
if(arabase[l1-1].H>arabase[l1].H)
{
ant tmpcls=arabase[l];
arabase[l1]=arabase[l1-1];
arabase[l1-1]=tmpcls;
}
else if(arabase[l1-1].H==arabase[l1].H)
{
if(arabase[l1-1].Vol>arabase[l1].Vol)
{
ant tmpcls=arabase[l];
arabase[l1]=arabase[l1-1];
arabase[l1-1]=tmpcls;
}
}
}
}
cout<<arabase[tc-1].Vol<<'\n';
delete[] arabase;
}
return 0;
}