comparable 奖牌榜 金银铜牌
来源:互联网 发布:多种乐器软件 编辑:程序博客网 时间:2024/05/15 19:31
import java.util.Arrays;
public class Result implements Comparable{
int j;
int y;
int t;
public Result(int j,int y,int t)
{
this.j = j;
this.y = y;
this.t = t;
}
public int compareTo(Object o) {
int point_j = ((Result)o).j;
int point_y = ((Result)o).y;
int point_t = ((Result)o).t;
int returnValue=0;
// if(j<point_j)
// returnValue=-1;
// else{
// if(j>point_j)
// returnValue=1;
// else{
// if(y<point_y)
// returnValue=-1;
// else{
// if(y>point_y)
// returnValue=1;
// else{
// if(t<point_t)
// returnValue=-1;
// else{
// if(t==point_t)
// returnValue=0;
// else returnValue=1;
//
// }
// }
///
// }
// }
// }
return j<point_j? 1:(j>point_j?-1:(y<point_y?1:(y>point_y?-1:(t<point_t?1:(t>point_t?-1:0)))));
}
public static void main(String[] args) {
Result[] ra = {new Result(50,2,30),new Result(50,2,56),new Result(86,3,43)};
Arrays.sort(ra);
for(int i=0;i<ra.length;i++)
{
System.out.println(ra[i].j + "," +ra[i].y+","+ra[i].t);
}
}
}
public class Result implements Comparable{
int j;
int y;
int t;
public Result(int j,int y,int t)
{
this.j = j;
this.y = y;
this.t = t;
}
public int compareTo(Object o) {
int point_j = ((Result)o).j;
int point_y = ((Result)o).y;
int point_t = ((Result)o).t;
int returnValue=0;
// if(j<point_j)
// returnValue=-1;
// else{
// if(j>point_j)
// returnValue=1;
// else{
// if(y<point_y)
// returnValue=-1;
// else{
// if(y>point_y)
// returnValue=1;
// else{
// if(t<point_t)
// returnValue=-1;
// else{
// if(t==point_t)
// returnValue=0;
// else returnValue=1;
//
// }
// }
///
// }
// }
// }
return j<point_j? 1:(j>point_j?-1:(y<point_y?1:(y>point_y?-1:(t<point_t?1:(t>point_t?-1:0)))));
}
public static void main(String[] args) {
Result[] ra = {new Result(50,2,30),new Result(50,2,56),new Result(86,3,43)};
Arrays.sort(ra);
for(int i=0;i<ra.length;i++)
{
System.out.println(ra[i].j + "," +ra[i].y+","+ra[i].t);
}
}
}
- comparable 奖牌榜 金银铜牌
- 链表->金银铜牌
- sdut acm 金银铜牌
- Olympic奖牌榜排序
- 奖牌来源多解放军算两次 全运会奖牌榜你看得懂吗
- Olympics期间,把奖牌榜也加上吧
- 2008北京第29届奥运会总奖牌榜
- 奥运奖牌榜的小调用,是新浪的。
- Comparable
- Comparable
- 奥运奖牌计数
- 奥运奖牌中文信息系统
- CCF NOI1025 统计奖牌
- 07:奥运奖牌计数
- 7. 奥运奖牌计数
- 金银价格,
- 金牌、银牌、铜牌
- 金牌、银牌、铜牌
- JS跨域名问题
- Carbide 联机调试惨痛经历
- ASP.NET画图系列之实现Bar图(柱状图)
- 失业日记
- java调用webservice
- comparable 奖牌榜 金银铜牌
- c语言中static 变量
- ASP.NET画图系列之另类Pie图(圆饼图)
- 硬盘分区计算方法 让你分出整数分区
- switch case,若无break
- mysql常用大全2-备份与恢复
- 公司合并 CIO如何参与合并规划流程
- 网站记录2008-11-08
- JS 移动Div层